谷歌地图方向API等效URL

Google Maps Directions API Equivalent URL

本文关键字:URL 等效 API 方向 谷歌地图      更新时间:2023-09-26

一直在寻找答案,却找不到。我正在使用谷歌地图V3 API来获取方向和地图。这一切都很好……

但我想提供一个沼泽标准的a标签链接到谷歌地图本身的等效方向。我有两个邮政编码。我如何生成一个谷歌地图方向URL基于2邮政编码或我的

 google.maps.DirectionsService

我将使用URL生成一个"View on google maps"按钮和一个"printable"按钮。

干杯!艾登

以下是不同Google Maps功能的一些标准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

查看这个Stackoverflow问题的链接

http://www.seomoz.org/ugc/everything-you-never-wanted-to-know-about-google-maps-parameters

saddr =

设置方向搜索的起始点。你也可以在侧边栏的方括号中添加文本,使其加粗。

daddr =

设置方向搜索的结束点,并再次将添加到括号中的文本加粗。你也可以添加"+to:",这将设置通过点。可以多次添加。

示例

自2014年11月4日起,此功能适用于iOS 8、Safari和iPhone 5C:

https://www.google.com/maps/dir/current+location/100 N Arlington Ave, Reno, NV 89509

它会自动打开谷歌地图,如果安装并带你到方向选择器屏幕。还请注意:如果您使用%20或CC_4作为空格,则无关紧要。