Commit b4accbf2ad0e76bb19571d4bde6f5189b5630967

Authored by weixin_45529955
1 parent 82e2dd1c

地图重新定位当前位置

@@ -98,7 +98,7 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> { @@ -98,7 +98,7 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> {
98 // } 98 // }
99 99
100 /// 获取定位权限 100 /// 获取定位权限
101 - _requestLocationPermission() async { 101 + _requestLocationPermission({bool forceCenter = false}) async {
102 await AmapLocation.instance.updatePrivacyShow(true); 102 await AmapLocation.instance.updatePrivacyShow(true);
103 await AmapLocation.instance.updatePrivacyAgree(true); 103 await AmapLocation.instance.updatePrivacyAgree(true);
104 bool canLocation = false; 104 bool canLocation = false;
@@ -128,7 +128,8 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> { @@ -128,7 +128,8 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> {
128 // App.sp.setString("lat", "39.684670899"); 128 // App.sp.setString("lat", "39.684670899");
129 // App.sp.setString("lng", "118.17630045"); 129 // App.sp.setString("lng", "118.17630045");
130 } else { 130 } else {
131 - if (widget.long == null || 131 + if (forceCenter ||
  132 + widget.long == null ||
132 widget.long == '' || 133 widget.long == '' ||
133 widget.long == 'null') { 134 widget.long == 'null') {
134 latitude = location.latLng!.latitude; 135 latitude = location.latLng!.latitude;
@@ -288,8 +289,7 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> { @@ -288,8 +289,7 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> {
288 bottom: w(10), 289 bottom: w(10),
289 child: InkWell( 290 child: InkWell(
290 onTap: () { 291 onTap: () {
291 - _controller!.setCenterCoordinate(  
292 - LatLng(latitudeLocation, longitudeLocation)); 292 + _requestLocationPermission(forceCenter: true);
293 }, 293 },
294 child: Container( 294 child: Container(
295 decoration: BoxDecoration( 295 decoration: BoxDecoration(