Google Maps Directions API等效网址

时间:2013-05-01 20:41:36

标签: javascript google-maps-api-3

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

但我想提供一个标准的A标签链接到谷歌地图本身的等效方向。我有2个邮政编码。如何根据2个邮政编码或我的

生成Google地图指示网址
 google.maps.DirectionsService

我将使用该网址生成“在Google地图上查看”按钮和“可打印”按钮。

干杯!艾登

3 个答案:

答案 0 :(得分:22)

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

答案 1 :(得分:10)

请参阅this Stackoverflow question

中的链接

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

SADDR =

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

DADDR =

设置方向搜索的结束点,并再次加粗括号中添加的任何文本。您还可以添加“+到:”,它将通过点设置。这些可以多次添加。

Example

答案 2 :(得分:2)

截至2014年11月4日,这适用于iPhone 5C上Safari上的iOS 8:

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

如果已安装,它将自动打开Goog​​le地图,并转到指示选择器屏幕。另请注意:如果您使用%20+作为空格,则无关紧要。