Google 地图路线 API 等效 URL

问题描述 投票:0回答:4

一直在寻找答案,找不到答案。我正在使用 Google Maps V3 API 来获取路线和地图。这一切都可以...

但我想提供一个沼泽标准的 A 标签链接,指向 Google 地图本身上的等效方向。我有 2 个邮政编码。如何根据 2 个邮政编码或我的

生成 Google 地图路线 URL
 google.maps.DirectionsService

我将使用该 URL 生成一个“在谷歌地图上查看”按钮和一个“可打印”按钮。

干杯!艾登

javascript google-maps-api-3
4个回答
37
投票

以下是不同 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

11
投票

请参阅此 Stackoverflow 问题

中的链接

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

萨德=

设置路线搜索的起点。您还可以在括号中添加文本,以在方向侧栏中将其加粗。

爸爸=

设置路线搜索的终点,并再次将括号中添加的任何文本加粗。您还可以添加“+to:”,这将通过点设置。这些可以多次添加。

示例


4
投票

自 2014 年 11 月 4 日起,此功能可在 iPhone 5C 上的 Safari 上的 iOS 8 上运行:

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

如果安装了 Google 地图,它将自动打开 Google 地图,并将您带到路线选择器屏幕。另请注意:使用

%20
+
来表示空格并不重要。


0
投票

以下页面由Google提供,似乎是权威指南: https://developers.google.com/maps/documentation/urls/get-started

© www.soinside.com 2019 - 2024. All rights reserved.