先看看百度SDK怎么介绍这两个API(POI检索和POI详情检索)
/// 检索基础信息类,所有类型Poi检索的基类 @interface BMKBasePoiSearchOption : NSObject { NSString*_keyword; int _pageIndex; int _pageCapacity; } ///搜索关键字 @property (nonatomic, strong) NSString *keyword; ///分页索引,可选,默认为0 @property (nonatomic, assign) intpageIndex; ///分页数量,可选,默认为10,最多为50 @property (nonatomic, assign) intpageCapacity;
///poi详情检索信息类 @interface BMKPoiDetailSearchOption : NSObject { NSString* _poiUid; } ///poi的uid,从poi检索返回的BMKPoiResult结构中获取 @property (nonatomic, strong) NSString* poiUid;
发起检索的代码
#pragma mark - 发起poi检索 -(void)beginSearchWithCenter:(CLLocationCoordinate2D)center andKeyWord:(NSString *优艾设计网_设计百科)key { // 发起检索 BMKNearbySearchOption *nearBySearchOption = [[BMKNearbySearchOption alloc]init]; nearBySearchOption.pageIndex= 0; nearBySearchOption.pageCapacity = 20; nearBySearchOption.location = center; nearBySearchOption.keyword= key; nearBySearchOption.radius = 5000; BOOL flag = [self.poisearch poiSearchNearBy:nearBySearchOption];if(flag) { //NSLog(@"周边检索发送成功"); TAG = 7; } else { //NSLog(@"周边检索发送失败"); } } }
返回POI搜索结果
#pragma mark - 返回搜索结果 //实现PoiSearchDeleage处理回调结果 /***返回POI搜索结果*@param searcher 搜索对象*@param poiResult 搜索结果列表*@param errorCode 错误号,@see BMKSearchErrorCode// */ - (void)onGetPoiResult:(BMKPoiSearch*)searcher result:(BMKPoiResult*)poiResultList errorCode:(BMKSearchErrorCode)error {if (error == BMK_SEARCH_NO_ERROR) { // 在此处理正常结果x self.mudata = [NSMutableArray new]; // 搜索结果数据源数组要在这里初始化,才会每次请求都有不一样的数据进去数组[poiResultList.poiInfoList enumerateObjectsUsingBlock:^(BMKPoiInfo*_Nonnull poiInfo, NSUInteger idx, BOOL * _Nonnull stop) { // 闭包SearchModel *MyModel = [[SearchModel alloc] init];if (MyModel) {// MyModel值不能为空MyModel.name = poiInfo.name; MyModel.address= poiInfo.address; MyModel.phone= poiInfo.phone; [self.mudata addObject:MyModel];self.poiUid = poiInfo.uid; // 取得uid// 发起POI详情检索 BMKPoiDetailSearchOption *detailSearchOption = [[BMKPoiDetailSearchOption alloc]init]; detailSearchOption.poiUid = self.poiUid; BOOL flag1 = [self.poisearchDetail poiDetailSearch:detailSearchOption];if(flag1) { NSLog(@"周边检索发送成功"); TAG = 7; } else { NSLog(@"周边检索发送失败"); } } else {//NSLog(@"搜索结果模型没有值"); return;} }]; } }
返回POI详情搜索结果
/***返回POI详情搜索结果*@param searcher 搜索对象*@param poiDetailResult 详情搜索结果*@param errorCode 错误号,@see BMKSearchErrorCode*/ - (void)onGetPoiDetailResult:(BMKPoiSearch*)searcher result:(BMKPoiDetailResult*)poiDetailResult errorCode:(BMKSearchErrorCode)errorCode { NSLog(@"POI详情搜索结果方法走了");NSLog(@"errorCode:%u",errorCode);NSLog(@"poiDetailResult detailUrl%@",poiDetailResult.detailUrl); }
POI详情搜索返回方法这个方法不走,麻烦帮忙看看问题出在哪。谢谢~
精彩评论