【发布时间】:2010-07-09 23:05:07
【问题描述】:
有没有办法使用 maps.google.com 的获取方向的功能,以便我可以从 url 传递方向的参数?
【问题讨论】:
-
查看我的更新以响应您的更新:)
标签: google-maps
有没有办法使用 maps.google.com 的获取方向的功能,以便我可以从 url 传递方向的参数?
【问题讨论】:
标签: google-maps
可以使用以下url参数。
saddr 为起始地址
daddr 为目标地址
网址是http://maps.google.com/maps?saddr=new+york&daddr=baltimore
您传入的值几乎可以是您可以在网络应用程序中输入的任何内容,即地点名称/纬度/经度/等。另外,请确保使用+ 字符作为空格。
【讨论】:
以下是一些用于不同 Google 地图功能的标准 HTML 链接。使用新语法,您可以链接到多个目的地方向(但是,使用查询参数是不可能的)- 请参见下面的最后一个示例。 I keep an updated post here.
//Spaces can be changed to "+" or encoded as "%20".
//Linking to a location (No directions)
https://www.google.com/maps?q=760+West+Genesee+Street+Syracuse+NY+13204
//No starting point (User input required to generate directions).
https://www.google.com/maps?daddr=760+West+Genesee+Street+Syracuse+NY+13204
//With a set location as starting point (Automatically generates directions with no user input required).
https://www.google.com/maps?saddr=760+West+Genesee+Street+Syracuse+NY+13204&daddr=314+Avery+Avenue+Syracuse+NY+13204
//With "My Location" as starting point (Automatically generates directions with no user input required).
https://www.google.com/maps?saddr=My+Location&daddr=760+West+Genesee+Street+Syracuse+NY+13204
//Current Location to Latitude and Longitude
https://www.google.com/maps?saddr=My+Location&daddr=43.12345,-76.12345
//Query search of a Latitude and Longitude
//Also shows setting a default zoom level
https://www.google.com/maps?ll=43.12345,-76.12345&q=food&z=14
//String search as destination
https://www.google.com/maps?saddr=My+Location&daddr=Pinckney+Hugo+Group
//Multiple destination directions (using new syntax). Check my linked post above for the most up-to-date versions.
https://www.google.com/maps/dir/760+W+Genesee+St+Syracuse+NY+13204/314+Avery+Ave+Syracuse+NY+13204/9090+Destiny+USA+Dr+Syracuse+NY+13204
【讨论】:
当然可以。
从 ATL 到 LAX 的路线:
http://maps.google.com/maps?saddr=atl&daddr=lax
更新:
亚特兰大到拉瓜迪亚到洛杉矶到安德劳机场......
http://maps.google.com/maps?source=s_d&saddr=ATL&daddr=LGA+to:LAX+to:AAP
【讨论】:
只要你有一个saddr和一个daddr,tt似乎你可以+to:在daddr之前或之后获得额外积分。也就是说,这两个是等价的:
https://maps.google.com/maps?source=s_d&saddr=ATL&daddr=LGA+to:LAX+to:AAP
和
https://maps.google.com/maps?source=s_d&saddr=ATL+to:LGA+to:LAX&daddr=AAP
【讨论】: