如何将地址转换为 Google 地图链接

问题描述 投票:0回答:3

我有以下代码从数据库中提取地址。

 <td class="center"><?php echo ($customer->address!='')?$customer->address:'NA';?></td>

并在管理区域显示地址。

我希望使用该地址链接到谷歌地图

<a href="maps.google.com/?p= {then the addy} "> {the addy} </a>

但是当我将链接添加到代码时,代码就中断了。

最近的尝试是

<td class="center"><a href="http://map.google.com/?p=<?php echo ($customer->address!='')?$customer->address:'NA';?>"><?php echo ($customer->address!='')?$customer->address:'NA';?></a></td>
php google-maps hyperlink
3个回答
6
投票

你的代码很好,应该可以工作,只需将你的谷歌地址更改为https://maps.google.com/maps?q=


1
投票

要获得有效的 Google 地图 URL,您只需访问 http://maps.google.com,输入您想要的地址,然后单击“链接按钮”。 您可以精简为仍然有效的较短版本。 例如:纽约曼哈顿第五大道 1 号就类似于 https://maps.google.co.uk/maps?q=1+5th+大道,曼哈顿,纽约+纽约,美国+州。 因此,只需在地址各部分之间添加“,”,并为每个空格添加“+”。


0
投票

反过来你会如何做?

我有一个 csv 格式的地址列表。例如:

https://www.google.com/maps/place/Cahoots+London/data=!4m2!3m1!1s0x487604d507ab69fb:0xbbfbc270f421a878 https://www.google.com/maps/place/Mr+Fogg's+杜松子酒+客厅/数据=!4m2!3m1!1s0x487604cdb617ba29:0xcef59d8e87aa23df

我想将这些转换为地图上的确切地址,即

13 Kingly Ct,卡纳比,伦敦 W1B 5PW 1 新排,伦敦 WC2N 4EA

有没有一种简单的方法可以批量处理 500 多个 URL?

© www.soinside.com 2019 - 2024. All rights reserved.