|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
import 'dart:convert'; |
|
|
|
|
import 'dart:io'; |
|
|
|
|
import 'dart:ui'; |
|
|
|
|
import 'package:flutter/cupertino.dart'; |
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; |
|
|
|
|
import 'package:flutter_baidu_mapapi_map/flutter_baidu_mapapi_map.dart'; |
|
|
|
@ -12,7 +13,6 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
|
|
|
import 'package:huixiang/utils/flutter_utils.dart'; |
|
|
|
|
import 'package:huixiang/utils/font_weight.dart'; |
|
|
|
|
import 'package:huixiang/utils/location.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart'; |
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
|
import 'package:permission_handler/permission_handler.dart'; |
|
|
|
|
import 'package:url_launcher/url_launcher.dart'; |
|
|
|
@ -72,10 +72,10 @@ class _LocationMap extends State<LocationMap> with WidgetsBindingObserver {
|
|
|
|
|
myAddress = result.locationDetail; |
|
|
|
|
myCity = result.city; |
|
|
|
|
if (distance == null) calculate(); |
|
|
|
|
AppUtils.coordConvert(myLatLng).then((value) { |
|
|
|
|
this.myLatLng = value; |
|
|
|
|
// AppUtils.coordConvert(myLatLng).then((value) { |
|
|
|
|
// this.myLatLng = value; |
|
|
|
|
locationShow(); |
|
|
|
|
}); |
|
|
|
|
// }); |
|
|
|
|
Location.getInstance().stopLocation(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -421,19 +421,19 @@ class _LocationMap extends State<LocationMap> with WidgetsBindingObserver {
|
|
|
|
|
BMFCoordinate startCoord = BMFCoordinate( |
|
|
|
|
positionSorta == false |
|
|
|
|
? myLatLng.latitude |
|
|
|
|
: double.tryParse(widget.arguments["lat"]), |
|
|
|
|
: latLng.latitude, |
|
|
|
|
positionSorta == false |
|
|
|
|
? myLatLng.longitude |
|
|
|
|
: double.tryParse(widget.arguments["lng"])); |
|
|
|
|
: latLng.longitude); |
|
|
|
|
String startName = ((positionSorta == false) ? "我的位置" : "终点"); |
|
|
|
|
// 去的位置 |
|
|
|
|
String endName = ((positionSorta == false) ? "终点" : "我的位置"); |
|
|
|
|
BMFCoordinate endCoord = BMFCoordinate( |
|
|
|
|
positionSorta == false |
|
|
|
|
? double.tryParse(widget.arguments["lat"]) |
|
|
|
|
? latLng.latitude |
|
|
|
|
: myLatLng.latitude, |
|
|
|
|
positionSorta == false |
|
|
|
|
? double.tryParse(widget.arguments["lng"]) |
|
|
|
|
? latLng.longitude |
|
|
|
|
: myLatLng.longitude); |
|
|
|
|
BMFOpenRouteOption routeOption = BMFOpenRouteOption( |
|
|
|
|
startCoord: startCoord, |
|
|
|
@ -472,7 +472,7 @@ class _LocationMap extends State<LocationMap> with WidgetsBindingObserver {
|
|
|
|
|
? 'assets/image/traffic_texture_unknown.png' |
|
|
|
|
: 'assets/image/traffic_texture_smooth.png' |
|
|
|
|
], |
|
|
|
|
width: Platform.isAndroid ? 16 :10, |
|
|
|
|
width: Platform.isAndroid ? 16 : 10, |
|
|
|
|
lineDashType: BMFLineDashType.LineDashTypeNone, |
|
|
|
|
lineCapType: BMFLineCapType.LineCapButt, |
|
|
|
|
lineJoinType: BMFLineJoinType.LineJoinRound); |
|
|
|
@ -545,8 +545,8 @@ class _LocationMap extends State<LocationMap> with WidgetsBindingObserver {
|
|
|
|
|
? BMFCoordinate(myLatLng?.latitude ?? 0, myLatLng?.longitude ?? 0) |
|
|
|
|
: latLng); |
|
|
|
|
BMFPlanNode to = BMFPlanNode( |
|
|
|
|
cityName: positionSorta == false ? (storeInfo?.city ?? "") : myCity, |
|
|
|
|
name: positionSorta == false ? (storeInfo?.address ?? "") : myAddress, |
|
|
|
|
// cityName: positionSorta == false ? (storeInfo?.city ?? "") : myCity, |
|
|
|
|
// name: positionSorta == false ? (storeInfo?.address ?? "") : myAddress, |
|
|
|
|
pt: positionSorta == false |
|
|
|
|
? latLng |
|
|
|
|
: BMFCoordinate(myLatLng?.latitude ?? 0, myLatLng?.longitude ?? 0)); |
|
|
|
@ -1073,7 +1073,7 @@ class _LocationMap extends State<LocationMap> with WidgetsBindingObserver {
|
|
|
|
|
onTap: () { |
|
|
|
|
setState(() { |
|
|
|
|
navigationState = 1; |
|
|
|
|
onOpenBaiduMapRoute(); |
|
|
|
|
showMapSelect(); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
@ -1106,6 +1106,41 @@ class _LocationMap extends State<LocationMap> with WidgetsBindingObserver {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
showMapSelect() { |
|
|
|
|
showCupertinoModalPopup( |
|
|
|
|
context: context, |
|
|
|
|
builder: (context) { |
|
|
|
|
return CupertinoActionSheet( |
|
|
|
|
actions: [ |
|
|
|
|
CupertinoActionSheetAction( |
|
|
|
|
child: Text( |
|
|
|
|
"百度地图", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
onPressed: () { |
|
|
|
|
onOpenBaiduMapRoute(); |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
}, |
|
|
|
|
isDefaultAction: true, |
|
|
|
|
isDestructiveAction: false, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
cancelButton: CupertinoActionSheetAction( |
|
|
|
|
onPressed: () { |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
}, |
|
|
|
|
child: Text(S.of(context).quxiao, |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Colors.blue, |
|
|
|
|
),), |
|
|
|
|
isDestructiveAction: true, |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<Widget> itemServer(String businessService) { |
|
|
|
|
if (businessService == null || businessService == "") return []; |
|
|
|
|
var list = businessService.split(","); |
|
|
|
@ -1153,10 +1188,10 @@ class _LocationMap extends State<LocationMap> with WidgetsBindingObserver {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
addMarker() async { |
|
|
|
|
// latLng = await AppUtils.coordConvert(BMFCoordinate(double.tryParse(widget.arguments["lat"]), |
|
|
|
|
// double.tryParse(widget.arguments["lng"]))); |
|
|
|
|
latLng = BMFCoordinate(double.tryParse(widget.arguments["lat"]), |
|
|
|
|
double.tryParse(widget.arguments["lng"])); |
|
|
|
|
latLng = await AppUtils.coordConvert(BMFCoordinate(double.tryParse(widget.arguments["lat"]), |
|
|
|
|
double.tryParse(widget.arguments["lng"]))); |
|
|
|
|
// latLng = BMFCoordinate(double.tryParse(widget.arguments["lat"]), |
|
|
|
|
// double.tryParse(widget.arguments["lng"])); |
|
|
|
|
|
|
|
|
|
if (bmfMarker == null && _mapController != null) { |
|
|
|
|
bmfMarker = BMFMarker.icon( |
|
|
|
|