作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的 flutter 代码中,我将通过单击按钮启动具有预定义位置的 Google map 应用程序。下面是代码
_launchMaps(double lat, double lon) async {
String googleUrl =
'comgooglemaps://?center=${lat},${lon}';
String appleUrl =
'https://www.google.com/maps/search/?api=1&query=$lat,$lon';
if (await canLaunch("comgooglemaps://")) {
print('launching com googleUrl');
await launch(googleUrl);
} else if (await canLaunch(appleUrl)) {
print('launching apple url');
await launch(appleUrl);
} else {
throw 'Could not launch url';
}
}
在 iOS 中,我确实将以下行添加到 info.plist 文件中
<key>LSApplicationQueriesSchemes</key>
<array>
<string>googlechromes</string>
<string>comgooglemaps</string>
</array>
在 Android
中,当我单击该按钮时,我会打开谷歌地图,并且我可以清楚地看到“方向”按钮,我可以单击该按钮并开始导航。下面的例子
在 iOS 中,我打开了 Google map ,位置在标记中指向,但我没有看到“方向”按钮或类似的按钮,因此我无法开始导航。我该如何解决这个问题?
最佳答案
如 docs 中所述,您需要在 URL 上定义起点经纬度和终点经纬度,以提示方向导航。 URL 应类似于:
comgooglemaps://?saddr={LAT},{LONG}&daddr={LAT},{LONG}&directionsmode=drive
关于android - flutter : How to launch the Google Map app with "directions" to a predefined location?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63921431/
我是一名优秀的程序员,十分优秀!