从网站打开 GoogleMaps 应用程序以在 android 上导航

Posted

技术标签:

【中文标题】从网站打开 GoogleMaps 应用程序以在 android 上导航【英文标题】:Open GoogleMaps app for navigation on android from website 【发布时间】: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 中打开路线?

【问题讨论】:

【参考方案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

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

【讨论】:

以上是关于从网站打开 GoogleMaps 应用程序以在 android 上导航的主要内容,如果未能解决你的问题,请参考以下文章

如果安装在 iphone 中,则在 facebook 中打开共享链接以在本机应用程序中打开

如何应用地理位置坐标从 googlemaps 获取到特定地点的路线?

是否可以检索网站源代码以在 iPhone 应用程序中进行解析?

从 JSON 写入/读取图像以在 Xcode 中使用

如何从网站中提取数据计数器以在另一个 HTML 项目中用作 JS 变量

我可以从网站上读取“真实”的移动 GPS 坐标吗?