// 百度PoiSearch查询
RCT_EXPORT_METHOD(PoiSearch:(NSString*)text AndCity:(NSString*)City)
{
//初始化搜索对象 ,并设置代理
_searcher =[[BMKPoiSearch alloc]init];
_searcher.delegate = self;
//请求参数类BMKCitySearchOption
BMKCitySearchOption *citySearchOption = [[BMKCitySearchOption alloc]init];
citySearchOption.pageIndex=0;
citySearchOption.pageCapacity=10;
citySearchOption.city= City;
citySearchOption.keyword= text;
//发起城市内POI检索
BOOLflag = [_searcherpoiSearchInCity:citySearchOption];
if(flag) {
NSLog(@"城市内检索发送成功");
}
else{
NSLog(@"城市内检索发送失败");
}
}
代理回调方法
- (void)onGetPoiDetailResult:(BMKPoiSearch*)searcher result:(BMKPoiDetailResult*)poiDetailResult errorCode:(BMKSearchErrorCode)errorCode{
}
- (void)onGetPoiIndoorResult:(BMKPoiSearch*)searcher result:(BMKPoiIndoorResult*)poiIndoorResult errorCode:(BMKSearchErrorCode)errorCode{
}
- (void)onGetPoiResult:(BMKPoiSearch*)searcher result:(BMKPoiResult*)poiResultList errorCode:(BMKSearchErrorCode)error
{
if (error == BMK_SEARCH_NO_ERROR) {
//在此处理正常结果
// BMKPoiInfo* poi = [poiResultList.poiInfoList objectAtIndex:0];
// NSLog(@"获得结果");
//
NSLog(@"%@,",poiResultList);
NSMutableArray *Data = [NSMutableArray array];
for(inti =0; i < poiResultList.poiInfoList.count; i++)
{
BMKPoiInfo* poi = [poiResultList.poiInfoListobjectAtIndex:i];
BMKPointAnnotation* item = [[BMKPointAnnotation alloc]init];
item.coordinate= poi.pt;
item.title= poi.name;
[DatainsertObject:@{
@"coordinate":@{
@"latitude":@(item.coordinate.latitude),
@"longitude":@(item.coordinate.latitude)
},
@"title":poi.name
}atIndex:i];
}
[self.bridge.eventDispatcher sendAppEventWithName:@"PoiSearch" body:@{@"Data":Data}];
}
else if (error == BMK_SEARCH_AMBIGUOUS_KEYWORD){
//当在设置城市未找到结果,但在其他城市找到结果时,回调建议检索城市列表
// result.cityList;
NSLog(@"起始点有歧义");
}
else{
NSLog(@"抱歉,未找到结果");
}
}
查看代理 必须有的回调(ctr+左击)
范围之内的都得实现