【发布时间】:2021-12-18 12:20:02
【问题描述】:
如何通过flutter react-native .. 或任何移动技术的 android 或 ios 上的另一个 apk 打开谷歌地图 apk。我想在我的应用程序中制作一个导航系统,所以我想通过我的应用程序直接使用谷歌地图。有人可以帮帮我吗?
【问题讨论】:
标签: android ios react-native flutter google-maps
如何通过flutter react-native .. 或任何移动技术的 android 或 ios 上的另一个 apk 打开谷歌地图 apk。我想在我的应用程序中制作一个导航系统,所以我想通过我的应用程序直接使用谷歌地图。有人可以帮帮我吗?
【问题讨论】:
标签: android ios react-native flutter google-maps
要从您的应用中打开 Google 地图应用,您可以执行以下操作。
首先设置您的 url 字符串(您将发送到 Google 地图应用程序以便它知道给出的方向):
String url = 'https://www.google.com/maps/dir/?api=1&origin=' +
currentLocation.latitude.toString() +
',' +
currentLocation.longitude.toString() +
' &destination=' +
lat.toString() +
',' +
lon.toString() +
'&travelmode=driving&dir_action=navigate';
_launchURL(url);
其中currentLocation表示用户当前位置,lat和lon表示目的地。
然后使用 urlLauncher 启动该 url:
void _launchURL(String url) async {
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
【讨论】: