【问题标题】:Google Maps Directions API Equivalent URLGoogle Maps Directions API 等效 URL
【发布时间】:2013-05-01 20:41:35
【问题描述】:

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

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

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

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

干杯!艾登

【问题讨论】:

    标签: javascript google-maps-api-3


    【解决方案1】:

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

    【讨论】:

    • 我不确定事情是如何改变的,但是使用 My+Location 不起作用,我改用 Current+Location
    • 这在 chrome / firefox / IE11 中运行良好,但当参数之一是“My+Location”/“Current+Location”时,我看不到它在 IE9 中运行。
    • 我在此处看到 IE9 和使用“我的+位置”/“当前+位置”的问题。它似乎在搜索实际文本而不是解释我的位置 - 有什么想法吗? google.com/…
    【解决方案2】:

    查看this Stackoverflow question中的链接

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

    saddr=

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

    daddr=

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

    Example

    【讨论】:

      【解决方案3】:

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

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

      如果已安装,它将自动打开 Google 地图,并带您进入路线选择器屏幕。另请注意:空格使用%20+ 无关紧要。

      【讨论】:

        猜你喜欢
        • 2016-10-22
        • 2015-12-12
        • 1970-01-01
        • 2011-05-24
        • 1970-01-01
        • 2015-07-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多