一: 在 http://lbsyun.baidu.com/index.php?title=ios-navsdk/sdkios-nav-download 下載導(dǎo)航的BaiduNaviSDK,并添加到工程里面昼汗。
二: 把baiduNaviSDK文件夾添加到工程中
把UserNotifications.framework洒疚、AudioToolbox.framework嗤瞎、ImageIO.framework、CoreMotion.framework、CoreLocation.framework、CoreTelephony.framework耐床、MediaPlayer.framework、AVFoundation.framework楔脯、SystemConfiguration.framework撩轰、JavaScriptCore.framework、Security.framework 昧廷、OpenGLES.framework 堪嫂、GLKit.framework 、libstdc++6.0.9.dylib木柬、libc++.tbd皆串、libsqlite3.0.tbd、libz.1.2.5.tbd這幾個framework添加到工程中眉枕,添加方法為在Xcode中單擊工程文件恶复,選擇Build Phrases選項,點擊Link Binary with Libraries下的“+”逐個添加速挑。另外thirdlibs中的兩個靜態(tài)庫libssl.a谤牡、libcrypto.a也要添加到工程中,如下所示:
三 : 配置.plist文件姥宝,如圖所示(畫紅線字段):
設(shè)置 “Required background modes”翅萤、 “App Transport Security Settings”(可以根據(jù)自身情況設(shè)置,導(dǎo)航sdk已經(jīng)全面支持https)腊满、 ”NSLocationAlwaysUsageDescription”套么、 ”NSLocationWhenInUseUsageDescription”、 ”View controller-based status bar appearance”糜烹、” LSApplicationQueriesSchemes”這6項
四: 開啟引擎
在APPDelegate里面開啟
//開啟引擎
[BNCoreServices_Instance initServices:@"申請的密鑰值"];
[BNCoreServices_Instance startServicesAsyn:nil fail:nil];
五: 發(fā)起導(dǎo)航
#pragma mark -- 發(fā)起導(dǎo)航
-(void)starNaviByBMKUserLocation:(BMKUserLocation *)userLocation{
//節(jié)點數(shù)組
NSMutableArray * nodesArray = [NSMutableArray array];
//起點
BNRoutePlanNode * startNode = [[BNRoutePlanNode alloc] init];
startNode.pos = [[BNPosition alloc] init];
startNode.pos.x = userLocation.location.coordinate.latitude;
startNode.pos.y = userLocation.location.coordinate.longitude;
startNode.pos.eType = BNCoordinate_BaiduMapSDK;
[nodesArray addObject:startNode];
//終點
BNRoutePlanNode * endNode = [[BNRoutePlanNode alloc] init];
endNode.pos = [[BNPosition alloc] init];
endNode.pos.x = userLocation.location.coordinate.latitude+ 10;
endNode.pos.y = userLocation.location.coordinate.longitude + 10;
endNode.pos.eType = BNCoordinate_BaiduMapSDK;
[nodesArray addObject:endNode];
//發(fā)起路徑規(guī)劃
[BNCoreServices_RoutePlan startNaviRoutePlan:BNRoutePlanMode_Recommend naviNodes:nodesArray time:nil delegete:self userInfo:nil];
}
#pragma mark -- BNNaviRoutePlanDelegate
-(void)routePlanDidFinished:(NSDictionary *)userInfo{
NSLog(@"路程計算成功");
//開始導(dǎo)航
[BNCoreServices_UI showPage:BNaviUI_NormalNavi delegate:self extParams:nil];
}