Baidu map navigation for iOS development and ios map navigation
This article describes the navigation functions of Baidu map:
Step 1: Before using Baidu navigation, We need to download the navigation SDK on the Baidu map open platform, which is 85.8 MB in total. students with poor network speed can prepare them in advance.
Step 2: introduce the system package required for navigation
Set AudioToolbox. framework, ImageIO. framework, CoreMotion. framework, CoreLocation. framework, CoreTelephony. framework, MediaPlayer. framework, AVFoundation. framework, SystemConfiguration. framework and libstdc ++ 6.0.9.dylib are added to the project.
Step 3: Set the TouchJSON library to a non-ARC compilation option, that is, set the compilation method in Compile Sources to-fno-objc-arc.
Step 4: Select media and then locate the background Mode
Step 5: add the header file and initiate navigation
# Import "BNCoreServices. h "// introduce the map navigation header file # pragma mark-pilot initiate navigation-(void) startNavi {// node array NSMutableArray * nodesArray = [[NSMutableArray alloc] initWithCapacity: 2]; // start point 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]; // end point: BNRoutePlanNode * endNode = [[BNRoutePlanNode alloc] init]; endNode. pos = [[BNPosition alloc] init]; endNode. pos. x = 114.077075; endNode. pos. y = 22.543634; endNode. pos. eType = role; [nodesArray addObject: endNode]; // initiate a path planning [BNCoreServices_RoutePlan startNaviRoutePlan: inclunavinodes: nodesArray time: nil delegete: self userInfo: nil];} # pragma mark-BNNaviUIManagerDelegate success callback-(void) routePlanDidFinished :( NSDictionary *) userInfo {NSLog (@ ""); // Path Planning successful, start navigation BN_NaviTypeSimulator default simulated navigation, BN_NaviTypeReal real machine navigation [BNCoreServices_UI showNaviUI: BN_NaviTypeSimulator delegete: self isNeedLandscape: YES];}