|
|
|
@ -138,31 +138,54 @@ class _AddressMapPage extends State<AddressMapPage> {
|
|
|
|
|
aMapFlutterLocation.prepareLoc(androidMap, iosMap); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<BMFPoiInfo> poiList; |
|
|
|
|
List<Address> poiList; |
|
|
|
|
|
|
|
|
|
searchPoi(BMFCoordinate latLng) async { |
|
|
|
|
keyWord = textEditingController.text; |
|
|
|
|
|
|
|
|
|
BMFPoiNearbySearch bmfPoiNearbySearch = BMFPoiNearbySearch(); |
|
|
|
|
bmfPoiNearbySearch.onGetPoiNearbySearchResult( |
|
|
|
|
callback: (BMFPoiSearchResult result, BMFSearchErrorCode errorCode) { |
|
|
|
|
// if ((DateTime.now().millisecondsSinceEpoch - time) > 2000) { |
|
|
|
|
result.poiInfoList.map((e) => print("sssssssssss:${e.toMap()}")); |
|
|
|
|
poiList = result.poiInfoList; |
|
|
|
|
print("object112221: ${poiList.length}"); |
|
|
|
|
setState(() { |
|
|
|
|
time = DateTime.now().millisecondsSinceEpoch; |
|
|
|
|
}); |
|
|
|
|
// } |
|
|
|
|
}); |
|
|
|
|
bmfPoiNearbySearch.poiNearbySearch(BMFPoiNearbySearchOption( |
|
|
|
|
keywords: ["附近"], |
|
|
|
|
radius: 100000, |
|
|
|
|
location: latLng, |
|
|
|
|
pageSize: 20, |
|
|
|
|
pageIndex: 0, |
|
|
|
|
isRadiusLimit: true, |
|
|
|
|
)); |
|
|
|
|
print("keyWord: ${keyWord}"); |
|
|
|
|
var addressPoi = await apiService.searchPoi( |
|
|
|
|
"${latLng.latitude}", "${latLng.longitude}", keyWord, 20, 1); |
|
|
|
|
List<dynamic> poi = addressPoi['pois']; |
|
|
|
|
poiList = poi |
|
|
|
|
.map((e) => Address.fromJson({ |
|
|
|
|
"address": e["address"] is List ? "" : e["address"], |
|
|
|
|
"area": e["adname"], |
|
|
|
|
"city": e["cityname"], |
|
|
|
|
"province": e["pname"], |
|
|
|
|
"latitude": e["location"].toString().split(",")[0], |
|
|
|
|
"longitude": e["location"].toString().split(",")[1], |
|
|
|
|
"cityInfo": e["name"], |
|
|
|
|
"id": "", |
|
|
|
|
"mid": "", |
|
|
|
|
"phone": "", |
|
|
|
|
"tag": "", |
|
|
|
|
"username": "", |
|
|
|
|
"isDefault": true, |
|
|
|
|
})) |
|
|
|
|
.toList(); |
|
|
|
|
setState(() {}); |
|
|
|
|
|
|
|
|
|
// BMFPoiNearbySearch bmfPoiNearbySearch = BMFPoiNearbySearch(); |
|
|
|
|
// bmfPoiNearbySearch.onGetPoiNearbySearchResult( |
|
|
|
|
// callback: (BMFPoiSearchResult result, BMFSearchErrorCode errorCode) { |
|
|
|
|
// // if ((DateTime.now().millisecondsSinceEpoch - time) > 2000) { |
|
|
|
|
// result.poiInfoList.map((e) => print("sssssssssss:${e.toMap()}")); |
|
|
|
|
// poiList = result.poiInfoList; |
|
|
|
|
// print("object112221: ${poiList.length}"); |
|
|
|
|
// setState(() { |
|
|
|
|
// time = DateTime.now().millisecondsSinceEpoch; |
|
|
|
|
// }); |
|
|
|
|
// // } |
|
|
|
|
// }); |
|
|
|
|
// bmfPoiNearbySearch.poiNearbySearch(BMFPoiNearbySearchOption( |
|
|
|
|
// keywords: [" "], |
|
|
|
|
// tags: ["小区","住宅","地标","建筑"], |
|
|
|
|
// radius: 100000, |
|
|
|
|
// location: latLng, |
|
|
|
|
// pageSize: 20, |
|
|
|
|
// pageIndex: 0, |
|
|
|
|
// isRadiusLimit: true, |
|
|
|
|
// )); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int time = 0; |
|
|
|
@ -240,11 +263,21 @@ class _AddressMapPage extends State<AddressMapPage> {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
BMFMapController _mapController; |
|
|
|
|
BMFCoordinate bmfCoordinate; |
|
|
|
|
|
|
|
|
|
void onMapCreated(BMFMapController controller) { |
|
|
|
|
controller.setMapRegionDidChangeCallback(callback: (status) { |
|
|
|
|
BMFMapStatus bmfMapStatus = status; |
|
|
|
|
print("status: ${bmfMapStatus.toMap()}"); |
|
|
|
|
if(bmfCoordinate != null && bmfCoordinate.longitude == status.targetGeoPt.longitude && bmfCoordinate.latitude == status.targetGeoPt.latitude) { |
|
|
|
|
if ((DateTime.now().millisecondsSinceEpoch - time) > 1000) { |
|
|
|
|
center = status.targetGeoPt; |
|
|
|
|
searchPoi(center); |
|
|
|
|
time = DateTime.now().millisecondsSinceEpoch; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
bmfCoordinate = status.targetGeoPt; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
setState(() { |
|
|
|
@ -265,7 +298,6 @@ class _AddressMapPage extends State<AddressMapPage> {
|
|
|
|
|
print("map_wid: ${MediaQuery.of(context).size.width}"); |
|
|
|
|
print("map_hei: ${MediaQuery.of(context).size.height}"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bmfMarker = BMFMarker( |
|
|
|
|
position: latLng, |
|
|
|
|
screenPointToLock: BMFPoint((Platform.isIOS ? MediaQuery.of(context).size.width : window.physicalSize.width) / 2, |
|
|
|
@ -392,7 +424,7 @@ class _AddressMapPage extends State<AddressMapPage> {
|
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
return InkWell( |
|
|
|
|
onTap: () { |
|
|
|
|
Navigator.of(context).pop(poiList[position].toMap()); |
|
|
|
|
Navigator.of(context).pop(poiList[position].toJson()); |
|
|
|
|
}, |
|
|
|
|
child: addressItem(poiList[position]), |
|
|
|
|
); |
|
|
|
@ -413,8 +445,7 @@ class _AddressMapPage extends State<AddressMapPage> {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget addressItem(BMFPoiInfo address) { |
|
|
|
|
print("addresss:${address.toMap()}"); |
|
|
|
|
Widget addressItem(Address address) { |
|
|
|
|
return Container( |
|
|
|
|
margin: EdgeInsets.symmetric(vertical: 16.h, horizontal: 16.w), |
|
|
|
|
child: Column( |
|
|
|
@ -422,7 +453,7 @@ class _AddressMapPage extends State<AddressMapPage> {
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
children: [ |
|
|
|
|
Text( |
|
|
|
|
address.name ?? "", |
|
|
|
|
address.cityInfo ?? "", |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|