iOS開發之百度地圖導航,ios地圖導航

來源:互聯網
上載者:User

iOS開發之百度地圖導航,ios地圖導航

本篇主要講述百度地圖的導航功能:

第一步:在使用百度導航之前,我們需要在百度地圖開放平台上下載導航的 SDK,共85.8M,網速不好的同學可提前準備好。

第二步:引入導航所需的系統包

  將AudioToolbox.framework、ImageIO.framework、CoreMotion.framework、CoreLocation.framework、CoreTelephony.framework、MediaPlayer.framework、AVFoundation.framework、SystemConfiguration.framework、libstdc++6.0.9.dylib這幾個framework添加到工程中。

第三步:將TouchJSON庫設定為非ARC編譯選項,也就是在 Compile Sources 中設定編譯方式為:-fno-objc-arc

第四步:勾選媒體後定位後台模式

第五步:添加標頭檔,發起導航

#import "BNCoreServices.h"// 引入地圖導航標頭檔#pragma mark - BNNaviRoutePlanDelegate 發起導航- (void)startNavi{    //節點數組    NSMutableArray *nodesArray = [[NSMutableArray alloc]    initWithCapacity:2];        //起點    BNRoutePlanNode *startNode = [[BNRoutePlanNode alloc] init];    startNode.pos = [[BNPosition alloc] init];    startNode.pos.x = 113.936392;    startNode.pos.y = 22.547058;    startNode.pos.eType = BNCoordinate_BaiduMapSDK;    [nodesArray addObject:startNode];        //終點    BNRoutePlanNode *endNode = [[BNRoutePlanNode alloc] init];    endNode.pos = [[BNPosition alloc] init];    endNode.pos.x = 114.077075;    endNode.pos.y = 22.543634;    endNode.pos.eType = BNCoordinate_BaiduMapSDK;    [nodesArray addObject:endNode];    //發起路徑規劃    [BNCoreServices_RoutePlan startNaviRoutePlan:BNRoutePlanMode_Recommend naviNodes:nodesArray time:nil delegete:self userInfo:nil];}#pragma mark#pragma mark - BNNaviUIManagerDelegate 算路成功回調-(void)routePlanDidFinished:(NSDictionary *)userInfo{    NSLog(@"算路成功");        //路徑規劃成功,開始導航 BN_NaviTypeSimulator 預設類比導航,BN_NaviTypeReal 真機導航    [BNCoreServices_UI showNaviUI: BN_NaviTypeSimulator delegete:self isNeedLandscape:YES];}

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.