|
...
|
...
|
@@ -66,10 +66,14 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> { |
|
|
|
|
|
|
|
/// 获取定位权限
|
|
|
|
_requestLocationPermission() async {
|
|
|
|
await AmapLocation.instance.updatePrivacyShow(true);
|
|
|
|
await AmapLocation.instance.updatePrivacyAgree(true);
|
|
|
|
bool canLocation = await requestPermission(Permission.location);
|
|
|
|
// 单次定位
|
|
|
|
if (canLocation) {
|
|
|
|
Future.delayed(Duration(milliseconds: 200), () async {
|
|
|
|
await AmapLocation.instance.updatePrivacyShow(true);
|
|
|
|
await AmapLocation.instance.updatePrivacyAgree(true);
|
|
|
|
final location = await AmapLocation.instance.fetchLocation(
|
|
|
|
// needAddress: true,
|
|
|
|
// mode: LocationAccuracy.High,
|
|
...
|
...
|
@@ -84,8 +88,11 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> { |
|
|
|
} else {
|
|
|
|
latitude = location.latLng.latitude;
|
|
|
|
longitude = location.latLng.longitude;
|
|
|
|
_controller.setCenterCoordinate(
|
|
|
|
LatLng(location.latLng.latitude, location.latLng.longitude));
|
|
|
|
if (_controller != null) {
|
|
|
|
_controller.setCenterCoordinate(
|
|
|
|
LatLng(location.latLng.latitude, location.latLng.longitude));
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
});
|
|
...
|
...
|
@@ -193,6 +200,8 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> { |
|
|
|
zoomLevel: 16,
|
|
|
|
onMapCreated: (controller) async {
|
|
|
|
_controller = controller;
|
|
|
|
_controller
|
|
|
|
.setCenterCoordinate(LatLng(latitude, longitude));
|
|
|
|
// if (await requestPermission(PermissionGroup.location)) {
|
|
|
|
// await controller.showMyLocation(true);
|
|
|
|
// await controller?.showLocateControl(true);
|
|
...
|
...
|
@@ -300,13 +309,18 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> { |
|
|
|
});
|
|
|
|
|
|
|
|
/// 逆地理编码(坐标转地址)
|
|
|
|
///
|
|
|
|
///
|
|
|
|
await AmapLocation.instance.updatePrivacyShow(true);
|
|
|
|
await AmapLocation.instance.updatePrivacyAgree(true);
|
|
|
|
ReGeocode reGeocodeList = await AmapSearch.instance.searchReGeocode(
|
|
|
|
latLng,
|
|
|
|
);
|
|
|
|
|
|
|
|
// print(await reGeocodeList.toFutureString());
|
|
|
|
address = await reGeocodeList.formatAddress;
|
|
|
|
|
|
|
|
address = reGeocodeList.formatAddress;
|
|
|
|
await AmapLocation.instance.updatePrivacyShow(true);
|
|
|
|
await AmapLocation.instance.updatePrivacyAgree(true);
|
|
|
|
final poiList = await AmapSearch.instance.searchKeyword(
|
|
|
|
address.toString(),
|
|
|
|
city: "西安",
|
|
...
|
...
|
@@ -334,6 +348,8 @@ class _MapChoicePointPageState extends State<MapChoicePointPage> { |
|
|
|
}
|
|
|
|
|
|
|
|
void searchAroundAddress(String text) async {
|
|
|
|
await AmapLocation.instance.updatePrivacyShow(true);
|
|
|
|
await AmapLocation.instance.updatePrivacyAgree(true);
|
|
|
|
final poiList = await AmapSearch.instance.searchKeyword(
|
|
|
|
text,
|
|
|
|
city: "西安",
|
...
|
...
|
|