【发布时间】:2021-01-03 08:48:26
【问题描述】:
在我的颤振代码中,我通过单击按钮启动具有预定义位置的 Google 地图应用程序。下面是代码
_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 中,我打开了谷歌地图,位置指向标记,但我没有得到“方向”按钮或类似的东西,所以我可以开始导航。我该如何解决这个问题?
【问题讨论】:
-
根据Maps URLs documentation,您可以使用以下 URL:
https://www.google.com/maps/dir/?api=1&parameters启动请求路线并使用结果启动 Google 地图。你试过吗? -
@PeakGen 你有什么成果吗?
标签: android ios google-maps flutter google-maps-markers