openMapByLatLng static method
Implementation
static Future<String?> openMapByLatLng(BuildContext context, String lat, String lng, String poi) async {
var packageInfo = await DeviceUtil.packageInfo;
String? urlGaode = await _canGaodeByLatLng(packageInfo, lat,lng,poi);
String? urlBaidu = await _canBaiduByLatLng(packageInfo, lat,lng,poi);
String? urlApple = await _canAppleByLatLng(packageInfo, lat,lng,poi);
/* if (urlGaode == null && urlBaidu == null && urlApple == null) {
var url = "https://ditu.amap.com/search?query=$address";
if (Platform.isIOS) {
url = Uri.encodeFull(url);
}
await launch(url);
return "h5";
}*/
List<Widget> list = <Widget>[];
String? action = "";
if (urlGaode != null) {
list.add(CupertinoActionSheetAction(child: Text("高德地图"), onPressed: () async => action = await _toMap(context, urlGaode, "amap")));
}
if (urlBaidu != null) {
list.add(CupertinoActionSheetAction(child: Text("百度地图"), onPressed: () async => action = await _toMap(context, urlBaidu, "baidu")));
}
if (urlApple != null) {
list.add(CupertinoActionSheetAction(child: Text("苹果地图"), onPressed: () async => action = await _toMap(context, urlApple, "apple")));
}
// var urlH5 = "https://ditu.amap.com/search?query=$address";
// if (Platform.isIOS) {
// urlH5 = Uri.encodeFull(urlH5);
// }
// list.add(CupertinoActionSheetAction(child: Text("网页版"), onPressed: () async => action = await _toMap(context, urlH5, "h5")));
await showCupertinoModalPopup(
context: context,
builder: (c) =>
CupertinoActionSheet(
title: Text("选择地图", style: TextStyle(fontSize: 18)),
cancelButton: CupertinoActionSheetAction(
child: Text("取消", style: TextStyle(color: Colors.red)),
onPressed: () {
action = "esc";
Navigator.pop(context);
}),
actions: list,
));
return action;
}