|
|
@ -11,9 +11,7 @@ import 'package:flutter/services.dart'; |
|
|
|
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; |
|
|
|
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; |
|
|
|
import 'package:flutter_baidu_mapapi_map/flutter_baidu_mapapi_map.dart'; |
|
|
|
import 'package:flutter_baidu_mapapi_map/flutter_baidu_mapapi_map.dart'; |
|
|
|
import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart'; |
|
|
|
import 'package:flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils.dart'; |
|
|
|
import 'package:flutter_bmflocation/bdmap_location_flutter_plugin.dart'; |
|
|
|
import 'package:flutter_bmflocation/flutter_bmflocation.dart'; |
|
|
|
import 'package:flutter_bmflocation/flutter_baidu_location_android_option.dart'; |
|
|
|
|
|
|
|
import 'package:flutter_bmflocation/flutter_baidu_location_ios_option.dart'; |
|
|
|
|
|
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart'; |
|
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart'; |
|
|
|
import 'package:huixiang/generated/l10n.dart'; |
|
|
|
import 'package:huixiang/generated/l10n.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/address.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/address.dart'; |
|
|
@ -61,42 +59,34 @@ class _AddressMapPage extends State<AddressMapPage> { |
|
|
|
|
|
|
|
|
|
|
|
if (aMapFlutterLocation == null) { |
|
|
|
if (aMapFlutterLocation == null) { |
|
|
|
aMapFlutterLocation = LocationFlutterPlugin(); |
|
|
|
aMapFlutterLocation = LocationFlutterPlugin(); |
|
|
|
aMapFlutterLocation.requestPermission(); |
|
|
|
|
|
|
|
aMapFlutterLocation.onResultCallback().listen((event) { |
|
|
|
|
|
|
|
print("event: ${jsonEncode(event)}"); |
|
|
|
|
|
|
|
if (event != null && |
|
|
|
|
|
|
|
event["latitude"] != null && |
|
|
|
|
|
|
|
event["longitude"] != null) { |
|
|
|
|
|
|
|
city = event["city"]; |
|
|
|
|
|
|
|
BMFCoordinate latLng; |
|
|
|
|
|
|
|
if (event["latitude"] is String && event["longitude"] is String) { |
|
|
|
|
|
|
|
latLng = BMFCoordinate(double.tryParse(event["latitude"]), |
|
|
|
|
|
|
|
double.tryParse(event["longitude"])); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
latLng = BMFCoordinate(event["latitude"], event["longitude"]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
BMFCalculateUtils.coordConvert( |
|
|
|
|
|
|
|
coordinate: latLng, |
|
|
|
|
|
|
|
fromType: BMF_COORD_TYPE.COMMON, |
|
|
|
|
|
|
|
toType: BMF_COORD_TYPE.BD09LL) |
|
|
|
|
|
|
|
.then((value) { |
|
|
|
|
|
|
|
saveLatLng(value); |
|
|
|
|
|
|
|
if (_mapController != null) { |
|
|
|
|
|
|
|
this.latLng = Platform.isIOS ? value : latLng; |
|
|
|
|
|
|
|
addMarker(); |
|
|
|
|
|
|
|
_mapController.updateMapOptions( |
|
|
|
|
|
|
|
BMFMapOptions( |
|
|
|
|
|
|
|
center: latLng, |
|
|
|
|
|
|
|
zoomLevel: 15, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
searchPoi(latLng); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
aMapFlutterLocation.singleLocationCallback(callback: (BaiduLocation result){ |
|
|
|
|
|
|
|
print("event: $result"); |
|
|
|
|
|
|
|
if (result != null && |
|
|
|
|
|
|
|
result.latitude != null && |
|
|
|
|
|
|
|
result.longitude != null) { |
|
|
|
|
|
|
|
city = result.city; |
|
|
|
|
|
|
|
BMFCoordinate latLng = BMFCoordinate(result.latitude, result.longitude); |
|
|
|
|
|
|
|
BMFCalculateUtils.coordConvert( |
|
|
|
|
|
|
|
coordinate: latLng, |
|
|
|
|
|
|
|
fromType: BMF_COORD_TYPE.COMMON, |
|
|
|
|
|
|
|
toType: BMF_COORD_TYPE.BD09LL) |
|
|
|
|
|
|
|
.then((value) { |
|
|
|
|
|
|
|
saveLatLng(value); |
|
|
|
|
|
|
|
if (_mapController != null) { |
|
|
|
|
|
|
|
this.latLng = Platform.isIOS ? value : latLng; |
|
|
|
|
|
|
|
addMarker(); |
|
|
|
|
|
|
|
_mapController.updateMapOptions( |
|
|
|
|
|
|
|
BMFMapOptions( |
|
|
|
|
|
|
|
center: latLng, |
|
|
|
|
|
|
|
zoomLevel: 15, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
searchPoi(latLng); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
_setLocOption(); |
|
|
|
_setLocOption(); |
|
|
|
|
|
|
|
|
|
|
|
getLatLng(); |
|
|
|
getLatLng(); |
|
|
@ -109,12 +99,12 @@ class _AddressMapPage extends State<AddressMapPage> { |
|
|
|
BaiduLocationAndroidOption androidOption = new BaiduLocationAndroidOption(); |
|
|
|
BaiduLocationAndroidOption androidOption = new BaiduLocationAndroidOption(); |
|
|
|
androidOption.setCoorType("GCJ02"); // 设置返回的位置坐标系类型 |
|
|
|
androidOption.setCoorType("GCJ02"); // 设置返回的位置坐标系类型 |
|
|
|
androidOption.setIsNeedAltitude(true); // 设置是否需要返回海拔高度信息 |
|
|
|
androidOption.setIsNeedAltitude(true); // 设置是否需要返回海拔高度信息 |
|
|
|
androidOption.setIsNeedAddres(true); // 设置是否需要返回地址信息 |
|
|
|
androidOption.setIsNeedAddress(true); // 设置是否需要返回地址信息 |
|
|
|
androidOption.setIsNeedLocationPoiList(true); // 设置是否需要返回周边poi信息 |
|
|
|
androidOption.setIsNeedLocationPoiList(true); // 设置是否需要返回周边poi信息 |
|
|
|
androidOption.setIsNeedNewVersionRgc(true); // 设置是否需要返回最新版本rgc信息 |
|
|
|
androidOption.setIsNeedNewVersionRgc(true); // 设置是否需要返回最新版本rgc信息 |
|
|
|
androidOption.setIsNeedLocationDescribe(true); // 设置是否需要返回位置描述 |
|
|
|
androidOption.setIsNeedLocationDescribe(true); // 设置是否需要返回位置描述 |
|
|
|
androidOption.setOpenGps(true); // 设置是否需要使用gps |
|
|
|
androidOption.setOpenGps(true); // 设置是否需要使用gps |
|
|
|
androidOption.setLocationMode(LocationMode.Hight_Accuracy); // 设置定位模式 |
|
|
|
androidOption.setLocationMode(BMFLocationMode.hightAccuracy); // 设置定位模式 |
|
|
|
androidOption.setScanspan(0); // 设置发起定位请求时间间隔 |
|
|
|
androidOption.setScanspan(0); // 设置发起定位请求时间间隔 |
|
|
|
|
|
|
|
|
|
|
|
Map androidMap = androidOption.getMap(); |
|
|
|
Map androidMap = androidOption.getMap(); |
|
|
@ -124,9 +114,9 @@ class _AddressMapPage extends State<AddressMapPage> { |
|
|
|
iosOption.setIsNeedNewVersionRgc(true); // 设置是否需要返回最新版本rgc信息 |
|
|
|
iosOption.setIsNeedNewVersionRgc(true); // 设置是否需要返回最新版本rgc信息 |
|
|
|
iosOption.setBMKLocationCoordinateType( |
|
|
|
iosOption.setBMKLocationCoordinateType( |
|
|
|
"BMKLocationCoordinateTypeGCJ02"); // 设置返回的位置坐标系类型 |
|
|
|
"BMKLocationCoordinateTypeGCJ02"); // 设置返回的位置坐标系类型 |
|
|
|
iosOption.setActivityType("CLActivityTypeAutomotiveNavigation"); // 设置应用位置类型 |
|
|
|
iosOption.setActivityType(BMFActivityType.automotiveNavigation); // 设置应用位置类型 |
|
|
|
iosOption.setLocationTimeout(10); // 设置位置获取超时时间 |
|
|
|
iosOption.setLocationTimeout(10); // 设置位置获取超时时间 |
|
|
|
iosOption.setDesiredAccuracy("kCLLocationAccuracyBest"); // 设置预期精度参数 |
|
|
|
iosOption.setDesiredAccuracy(BMFDesiredAccuracy.best); // 设置预期精度参数 |
|
|
|
iosOption.setReGeocodeTimeout(10); // 设置获取地址信息超时时间 |
|
|
|
iosOption.setReGeocodeTimeout(10); // 设置获取地址信息超时时间 |
|
|
|
iosOption.setDistanceFilter(1000); // 设置定位最小更新距离 |
|
|
|
iosOption.setDistanceFilter(1000); // 设置定位最小更新距离 |
|
|
|
iosOption.setAllowsBackgroundLocationUpdates(true); // 是否允许后台定位 |
|
|
|
iosOption.setAllowsBackgroundLocationUpdates(true); // 是否允许后台定位 |
|
|
|