iOS使用百度地图 获取云检索数据

ARVR技术交流qq群 602929993
ARVR训练营:www.arvrthink.com

项目集成百度SDK 参考http://blog.csdn.net/chuan403082010/article/details/77478182

添加云检索 数据参考http://blog.csdn.net/chuan403082010/article/details/77477312

.先创建iOS端AK 和服务端的AKhttp://lbsyun.baidu.com/apiconsole/key

创建项目, Display Name与Bundle Identifier  与刚才创建AK时填写的要一致

#import "AppDelegate.h"
#import <BaiduMapAPI_Map/BMKMapComponent.h>
@interface AppDelegate ()
@property (strong, nonatomic) BMKMapManager * mapManager;
@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    _mapManager = [[BMKMapManager alloc]init];
    //使用iOS端的ak
    BOOL ret = [_mapManager start:@"lrlaVPD6IzjI65TRRon1qMaegyOjQddD" generalDelegate:nil];
    if(ret){
        NSLog(@"Manager start failed");
    }else{
       NSLog(@"Manager start");
    }
    // Override point for customization after application launch.
    return YES;
}

#import "ViewController.h"
#import <BaiduMapAPI_Cloud/BMKCloudSearch.h>//检索
@interface ViewController ()<BMKCloudSearchDelegate>
@property (strong, nonatomic) BMKCloudSearch * search;

@end

@implementation ViewController


- (void)viewDidLoad {
    [super viewDidLoad];

    _search = [[BMKCloudSearch alloc]init];
    _search.delegate = self;
    
    [self startSearch];
    
    // Do any additional setup after loading the view, typically from a nib.
}


-(void)startSearch
{
    //周边检索
    BMKCloudNearbySearchInfo * cloudNearbySearch = [[BMKCloudNearbySearchInfo alloc]init];
    cloudNearbySearch.ak = @"bf0RbhE8DOsSBuyEDasmaPGGSURdnVke";//使用服务端的ak
    cloudNearbySearch.geoTableId = 174599;//填写的id为数据库表的id
    cloudNearbySearch.pageIndex = 0;
    cloudNearbySearch.pageSize = 10;
    cloudNearbySearch.location =  @"108.900255,34.163963";
    cloudNearbySearch.radius = 10000;
    cloudNearbySearch.keyword = @"5";
    
    BOOL flag = [_search nearbySearchWithSearchInfo:cloudNearbySearch];
    if (flag) {
        NSLog(@"周边检索发送成功");
    }else{
        NSLog(@"周边检索发送失败");
    }
}

/**
 *返回云检索POI列表结果
 *@param poiResultList 云检索结果列表,成员类型为BMKCloudPOIList
 *@param type 返回结果类型: BMK_CLOUD_LOCAL_SEARCH,BMK_CLOUD_NEARBY_SEARCH,BMK_CLOUD_BOUND_SEARCH
 *@param error 错误号,@see BMKCloudErrorCode
 */
- (void)onGetCloudPoiResult:(NSArray*)poiResultList searchType:(int)type errorCode:(int)error
{
    BMKCloudPOIList * result = [poiResultList objectAtIndex:0];
    NSLog(@"Count %ld",result.POIs.count);
    for (int i = 0; i < result.POIs.count; i++) {
        BMKCloudPOIInfo *poi = [result.POIs objectAtIndex:i];
        NSLog(@"%@ weight:%f  distance:%f", poi.title,poi.weight,poi.distance);
       for(NSString * key in poi.customDict.allKeys)
         {
          NSLog(@"%@ : %@",key,poi.customDict[key]);
         }
    }
}

/**
 *返回云检索POI详情
 *@param poiDetailResult 类型为BMKCloudPOIInfo
 *@param type 返回结果类型: BMK_CLOUD_DETAIL_SEARCH
 *@param error 错误号,@see BMKCloudErrorCode
 */
- (void)onGetCloudPoiDetailResult:(BMKCloudPOIInfo*)poiDetailResult searchType:(int)type errorCode:(int)error
{
    
}

/**
 *返回云RGC检索结果
 *@param cloudRGCResult 搜索结果
 *@param type 返回结果类型: BMK_CLOUD_RGC_SEARCH
 *@param error 错误号,@see BMKCloudErrorCode
 */
- (void)onGetCloudReverseGeoCodeResult:(BMKCloudReverseGeoCodeResult*)cloudRGCResult searchType:(BMKCloudSearchType) type errorCode:(NSInteger) errorCode{
    
}

@end




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值