【问题标题】:Open GoogleMaps app for navigation on android from website从网站打开 GoogleMaps 应用程序以在 android 上导航
【发布时间】:2019-04-08 12:53:30
【问题描述】:

我正在编写一个 Angular 4 网站,该网站从服务器接收 lat/lng 列表,并有一个引用 Google 地图并构建路线的按钮。

我的愿望是让用户使用 Google 地图应用导航到这些位置

我正在创建网址:

http://maps.google.com/maps/dir/{origin lat},{origin lng}/{destination lat 1},{destination lng 1}/{destination lat 2},{destination lng 2}/{destination lat 3},{destination lng 3}/data=!3m1!4b1!4m2!4m1!3e0

然后通过以下方式引用应用程序:

var win = window.open(url, '_blank');
win.focus();

在 iPhone/iPad 上,它可以完美运行,并且应用会随路线一起打开, 在桌面上,它指的是带有路线的谷歌地图站点。 但是在 android 上,它会打开 GoogleMaps 应用程序,但没有路线。

(GoogleMaps 应用程序已安装在所有 iPohnes/iPads/android 设备上 睾丸)

我怎样才能让 GoogleMaps 应用也能在 android 中打开路线?

【问题讨论】:

    标签: javascript android angular google-maps mobile-website


    【解决方案1】:

    路线 — 请求路线并使用结果启动 Google 地图:

    https://www.google.com/maps/dir/?api=1&parameters
    

    文档: https://developers.google.com/maps/documentation/urls/guide

    【讨论】:

      【解决方案2】:

      感谢 Gowthaman M, 必须像这样重新格式化 android 的 url:

      https://www.google.com/maps/dir/?api=1&origin={origin lat},{origin lng}&destination={destination lat 1},{destination lng 1}&waypoints={destination lat 2},{destination lng 2}|{destination lat 3},{destination lng 3}&travelmode=driving
      

      现在安卓正在打开带有路线的谷歌地图应用程序。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-05-18
        • 2015-04-01
        • 1970-01-01
        • 1970-01-01
        • 2012-12-24
        • 2015-10-08
        • 2016-07-11
        • 1970-01-01
        相关资源
        最近更新 更多