在网上搜索了一段时间后,我找不到任何像这样的地址:

宾夕法尼亚大街东南1200号 华盛顿,哥伦比亚特区,20003年

并将其转换为可点击的链接:

http://maps.google.com/maps?f=q&source=s_q&hl=en&q=1200+Pennsylvania+Ave+SE,+Washington,+District+of+Columbia,+20003&sll=37.0625,-95.677068&sspn=44.118686,114.169922&ie=UTF8&cd=1&geocode=FT5MUQIdIDlp-w&split=0&ll=38.882147,-76.99017&spn=0.01064,0.027874&z=16&iwloc=A

jQuery或PHP是首选或者任何有用的信息。


当前回答

另外,任何想要手动URLENCODE地址的人:http://code.google.com/apis/maps/documentation/webservices/index.html#BuildingURLs

您可以使用它来创建满足GM标准的特定规则。

其他回答

http://maps.google.com/maps?q=<?php echo urlencode($address); ?> 

encode ur conver并添加所有额外的元素,如for空格和all。所以你可以很容易地从db中获取平面文本代码并使用它,而不用担心要添加的特殊字符

另外,任何想要手动URLENCODE地址的人:http://code.google.com/apis/maps/documentation/webservices/index.html#BuildingURLs

您可以使用它来创建满足GM标准的特定规则。

如果你有纬度和经度,你可以使用波纹URL的任何部分或全部

https://www.google.com/maps/@LATITUDE,LONGITUDE,ZOOMNUMBERz?hl=LANGUAGE

例如: https://www.google.com/maps/@31.839472,54.361167,18z?hl=en

在http://www.labnol.org/internet/tools/short-urls-for-google-maps/6604/上,他们显示了一个简短的URL,工作得很好

地图url是相当笨拙的,特别是在发送即时消息,推特或电子邮件时。MapOf。它为您提供了一个快速的方法来链接到谷歌地图,只需指定位置的地址作为搜索参数。

http://mapof.it/

我在自己设计的几个应用程序中使用了它,效果非常好。

我知道我来得太晚了,但我想为了子孙后代,我应该有所贡献。

我写了一个简短的jQuery函数,将自动将任何<地址>标记转换为谷歌地图链接。

点击这里查看演示。

$(document).ready(function () {
   //Convert address tags to google map links - Michael Jasper 2012
   $('address').each(function () {
      var link = "<a href='http://maps.google.com/maps?q=" + encodeURIComponent( $(this).text() ) + "' target='_blank'>" + $(this).text() + "</a>";
      $(this).html(link);
   });
});

奖金:

我还遇到过一种需要从链接中生成嵌入式地图的情况,尽管我想与未来的旅行者分享:

查看完整演示

$(document).ready(function(){
    $("address").each(function(){                         
        var embed ="<iframe width='425' height='350' frameborder='0' scrolling='no'  marginheight='0' marginwidth='0' src='https://maps.google.com/maps?&amp;q="+ encodeURIComponent( $(this).text() ) +"&amp;output=embed'></iframe>";
        $(this).html(embed);             
    });
});