【问题标题】:is there a way to pass arguments to google map's get directions functionality?有没有办法将参数传递给谷歌地图获取路线功能?
【发布时间】:2010-07-09 23:05:07
【问题描述】:

有没有办法使用 maps.google.com 的获取方向的功能,以便我可以从 url 传递方向的参数?

【问题讨论】:

  • 查看我的更新以响应您的更新:)

标签: google-maps


【解决方案1】:

可以使用以下url参数。

saddr 为起始地址

daddr 为目标地址

网址是http://maps.google.com/maps?saddr=new+york&daddr=baltimore

您传入的值几乎可以是您可以在网络应用程序中输入的任何内容,即地点名称/纬度/经度/等。另外,请确保使用+ 字符作为空格。

【讨论】:

  • 嘿,谢谢您的信息...我还有一个问题:如果您想要前往 2 个以上的地方怎么办...例如纽约到巴尔的摩,然后到费城或任何其他地方任意数量的方向
  • 所以,daddr 始终是第 2 站。要添加更多航点,您只需添加“+to:whatever”。所以你的例子是maps.google.com/…
【解决方案2】:

以下是一些用于不同 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

【讨论】:

    【解决方案3】:

    当然可以。

    从 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

    【讨论】:

      【解决方案4】:

      只要你有一个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

      【讨论】:

        猜你喜欢
        • 2015-09-28
        • 1970-01-01
        • 2011-03-18
        • 1970-01-01
        • 1970-01-01
        • 2011-06-27
        • 2012-12-08
        • 2012-02-25
        • 1970-01-01
        相关资源
        最近更新 更多