【发布时间】:2018-04-13 06:50:57
【问题描述】:
我正在尝试检测 iOS 上是否安装了 Google Maps 应用,如果是,则启动它,如果没有,启动 Apple Maps。这是我目前所拥有的,但在我安装了谷歌地图的手机上,它没有检测到它并正确启动。
有什么想法吗?
import 'package:url_launcher/url_launcher.dart';
_launchMaps() async {
String googleUrl =
'comgooglemaps://?center=${trip.origLocationObj.lat},${trip.origLocationObj.lon}';
String appleUrl =
'https://maps.apple.com/?sll=${trip.origLocationObj.lat},${trip.origLocationObj.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';
}
}
我从这里提取了 url 方案:How would I be able to open google maps when I press a button in my app?
【问题讨论】:
标签: google-maps flutter