有没有办法将参数传递给谷歌地图的获取方向功能?

kam*_*lot 35 google-maps

有没有办法使用maps.google.com获取方向的功能,以便我可以传递来自网址的路线的参数?

Nic*_*eri 44

您可以使用以下url参数.

saddr 为起始地址

daddr 目的地址

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

您传入的值可以是您可以在Web应用程序中输入的任何内容,即place/lat longs/etc的名称.另外,请确保使用+空格字符.

  • 所以,daddr总是停在第2位.要添加更多的航路点,你只需添加"+ to:whatever".所以你的例子是http://maps.google.com/maps?saddr=new+york&daddr=baltimore+to:philadelphia+to:cleveland (6认同)

Gre*_*kes 26

以下是针对不同Google地图功能的一些标准HTML链接.使用新语法,您可以链接到多个目标方向(但是,查询参数不可用) - 请参阅下面的最后一个示例.我在这里保留更新的帖子.

//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
Run Code Online (Sandbox Code Playgroud)