如何将地址转换为Google Maps Link(NOT MAP)

本文翻译自:How to convert an address into a Google Maps Link (NOT MAP)

After looking (Googling) on the web for a while, I can find nothing that takes an address like: 在网上浏览(Google搜寻)一段时间后,我找不到任何需要以下地址的地址:

1200 Pennsylvania Ave SE, Washington, District of Columbia, 20003 哥伦比亚特区华盛顿,宾夕法尼亚大道1200号,20003

and converts it into a clickable link: 并将其转换为可点击的链接:

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 http://maps.google.com/maps?f=q&source=s_q&hl=zh_CN&q=1200+宾夕法尼亚州+ Ave + SE,+华盛顿,+ District + of + Columbia,+ 20003&sll = 37.0625,-95.677068&sspn = 44.118686,114.169922922 &ie = UTF8&cd = 1&geocode = FT5MUQIdIDlp-w&split = 0&ll = 38.882147,-76.99017&spn = 0.01064,0.027874&z = 16&iwloc = A

jQuery or PHP preferred or just any useful information on this. 首选jQuery或PHP或仅提供与此相关的任何有用信息。


#1楼

参考:https://stackoom.com/question/5spg/如何将地址转换为Google-Maps-Link-NOT-MAP


#2楼

怎么办: http : //support.google.com/maps/bin/answer.py?hl=zh_CN&answer=72644


#3楼

How about this? 这个怎么样?

https://maps.google.com/?q=1200 Pennsylvania Ave SE, Washington, District of Columbia, 20003 https://maps.google.com/?q=1200 Pennsylvania Ave SE,华盛顿特区,哥伦比亚特区,20003

https://maps.google.com/?q=term

If you have lat-long then use below URL 如果您有经纬度,请使用以下网址

https://maps.google.com/?ll=latitude,longitude

Example: maps.google.com/?ll=38.882147,-76.99017 示例: maps.google.com/?ll = 38.882147,-76.99017

UPDATE 更新

As of year 2017, Google now has an official way to create cross-platform Google Maps URLs: 自2017年起,Google现在拥有创建跨平台Google Maps URL的正式方法:

https://developers.google.com/maps/documentation/urls/guide https://developers.google.com/maps/documentation/urls/guide

You can use links like 您可以使用类似的链接

https://www.google.com/maps/search/?api=1&query=1200%20Pennsylvania%20Ave%20SE%2C%20Washington%2C%20District%20of%20Columbia%2C%2020003 

#4楼

The best way is to use this line: 最好的方法是使用以下行:

var mapUrl = "http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=16900+North+Bay+Road,+Sunny+Isles+Beach,+FL+33160&aq=0&sll=37.0625,-95.677068&sspn=61.282355,146.513672&ie=UTF8&hq=&hnear=16900+North+Bay+Road,+Sunny+Isles+Beach,+FL+33160&spn=0.01628,0.025663&z=14&iwloc=A&output=embed"

Remember to replace the first and second addresses when necessary. 请记住在必要时替换第一和第二地址。

You can look at work sample 你可以看一下工作样本


#5楼

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

the encode ur conver and adds all the extra elements like for spaces and all. 编码转换,并添加所有多余的元素,例如空格和all。 so u can easily fetch plane text code from db and use it without worring about the special characters to be added 因此,您可以轻松地从db获取平面文本代码并使用它,而不必担心要添加的特殊字符


#6楼

C#替换方法通常对我有用:

foo = "http://maps.google.com/?q=" + address.Text.Replace(" ","+");
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值