【发布时间】:2018-12-22 14:16:38
【问题描述】:
【问题讨论】:
-
你找到解决办法了吗?
标签: google-maps navigation mkmapview flutter android-mapview
【问题讨论】:
标签: google-maps navigation mkmapview flutter android-mapview
您可以在 Flutter 中使用 android_intent 库来启动 googlemaps 并在 android 中获取 diction。
库:https://pub.dartlang.org/packages/android_intent
在 ios 中,您可以使用 comgooglemaps 之类的 google api 或 google map url {i choose this one} 和 maps.apple.com。
String origin="somestartLocationStringAddress or lat,long"; // lat,long like 123.34,68.56
String destination="someEndLocationStringAddress or lat,long";
if (new LocalPlatform().isAndroid) {
final AndroidIntent intent = new AndroidIntent(
action: 'action_view',
data: Uri.encodeFull(
"https://www.google.com/maps/dir/?api=1&origin=" +
origin + "&destination=" + destination + "&travelmode=driving&dir_action=navigate"),
package: 'com.google.android.apps.maps');
intent.launch();
}
else {
String url = "https://www.google.com/maps/dir/?api=1&origin=" + origin + "&destination=" + destination + "&travelmode=driving&dir_action=navigate";
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
希望对你有帮助。
【讨论】:
在撰写此答案时,内联地图的工作仍在进行中。但是由于 Flutter 的人已经给了其他人开发插件的能力,所以有一些替代方案。
您可能想签出:
https://medium.com/@matthew.smith_66715/maps-in-flutter-a1ac49ab554b
如果您只想获取用户的位置:
https://pub.dartlang.org/packages/location
如果您想留意新的更新,我在这里发现了一些有趣的讨论:
【讨论】: