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