发布网友 发布时间:2022-04-23 07:33
共1个回答
热心网友 时间:2022-06-17 18:12
12345678/***根据中心点、半径和检索词发起周边检索*异步函数,返回结果在BMKPoiSearchDelegate的onGetPoiResult通知*@paramoption周边搜索的搜索参数类(BMKNearbySearchOption)*@paramindex页码,如果是第一次发起搜索,填0,根据返回的结果可以去获取第n页的结果,页码从0开始*@return成功返回YES,否则返回NO*/-(BOOL)poiSearchNearBy:(BMKNearbySearchOption*)option;12345678910111213141516171819_searcher=[[BMKPoiSearchalloc]init];_searcher.delegate=self;BMKNearbySearchOption*option=[[BMKNearbySearchOptionalloc]init];option.pageIndex=0;//起始页option.pageCapacity=30;//每页条数option.location=_locationCoordinate;//中心点option.keyword=self.keywordTF.text;//关键词option.sortType=BMK_POI_SORT_BY_DISTANCE;//根据距离排序option.radius=3000;//半径BOOLflag=[_searcherpoiSearchNearBy:option];if(flag){NSLog(@"周边检索发送成功");}else{NSLog(@"周边检索发送失败");}12345678910111213141516171819202122//实现PoiSearchDeleage处理回调结果-(void)onGetPoiResult:(BMKPoiSearch*)searcherresult:(BMKPoiResult*)poiResulterrorCode:(BMKSearchErrorCode)errorCode{if(errorCode==BMK_SEARCH_NO_ERROR){//在此处理正常结果_result=poiResult;[_mapViewremoveAnnotations:[_mapViewannotations]];for(inti=0;i<poiResult.poiInfoList.count;i++){BMKPoiInfo*info=[poiResult.poiInfoListobjectAtIndex:i];BMKPointAnnotation*annotation=[[BMKPointAnnotationalloc]init];annotation.title=info.name;annotation.subtitle=info.address;annotation.coordinate=info.pt;[_mapViewaddAnnotation:annotation];}self.resultNumLabel.text=FORMATSTRING(@"共找到“%@”相关%d个结果",self.keywordTF.text,poiResult.currPoiNum);}else{self.resultNumLabel.text=FORMATSTRING(@"抱歉,未找到“%@”相关的结果",self.keywordTF.text);}}