static Future<bool> gotoAMap(PageDatum data) async {
var sUrl = Uri.encodeComponent("|");
LatLng fromLatLng = LatLng(double.parse(data.traveInfo.first.locationY),
double.parse(data.traveInfo.first.locationX));
LatLng toLatLng = LatLng(double.parse(data.traveInfo.last.locationY),
double.parse(data.traveInfo.last.locationX));
String fromName = Uri.encodeComponent(data.traveInfo.first.name);
String toName = Uri.encodeComponent(data.traveInfo.last.name);
List vianLat = []; //途径点latlng
List vianLon = []; //途径点longlng
List vianName = []; //途径点名
if (data.traveInfo.length > 2) {
data.traveInfo.removeAt(0);
data.traveInfo.removeLast();
data.traveInfo.forEach((element) {
vianLat.add(element.locationY);
vianLon.add(element.locationX);
vianName.add(Uri.encodeComponent(element.name));
});
}
String latString = vianLat.join(sUrl);
String longString = vianLon.join(sUrl);
String nameString = vianName.join(sUrl);
var url = 'amapuri://drive/multiViaPointPlan/?sid=(null)&slat=${fromLatLng.latitude}&slon=${fromLatLng.longitude}&sname=$fromName&did=(null)&dlat=${toLatLng.latitude}&dlon=${toLatLng.longitude}&dname=$toName&dev=0&m=0&t=0&vian=${data.traveInfo.length}&vialons=$longString&vialats=$latString&vianames=$nameString';
bool canLaunchUrl = await canLaunch(url);
if (!canLaunchUrl) {
ToastTool.instance.toast("请安装高德地图");
return false;
}
await launch(url);
return true;
}
fromLatLngL: 起点经纬度
toLatLng: 终点经纬度
vian:途径点数量
vialons:途径点经度,字符串,多个以 | 间隔,
vialats:途径点纬度,字符串,多个以 | 间隔,
vianames:途径点名字,字符串,多个以 | 间隔,
中文以及 | 要单独编码才能识别