From fb612aadb7dc587c28b32bbd3a52636d98f95fa4 Mon Sep 17 00:00:00 2001 From: fmk Date: Mon, 9 Aug 2021 18:35:56 +0800 Subject: [PATCH] image --- lib/address/address_map_page.dart | 89 +++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 29 deletions(-) diff --git a/lib/address/address_map_page.dart b/lib/address/address_map_page.dart index 63cb0712..5bfdc850 100644 --- a/lib/address/address_map_page.dart +++ b/lib/address/address_map_page.dart @@ -138,31 +138,54 @@ class _AddressMapPage extends State { aMapFlutterLocation.prepareLoc(androidMap, iosMap); } - List poiList; + List
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 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 { } BMFMapController _mapController; + BMFCoordinate bmfCoordinate; void onMapCreated(BMFMapController controller) { controller.setMapRegionDidChangeCallback(callback: (status) { - center = status.targetGeoPt; - searchPoi(center); + 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 { 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 { 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 { ); } - 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 { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - address.name ?? "", + address.cityInfo ?? "", overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 16.sp,