Because the iOS Mapkit framework is not enough to meet our needs, we can choose to integrate Baidu Map, then how to do it?
Apply for key
Login to Baidu API Management Center to apply for key
Http://lbsyun.baidu.com/apiconsole/key
Create an App
The arrow means the key we're going to use.
Download SDK
Http://developer.baidu.com/map/static/doc/output_ios/BaiduMap_IOSSDK_v2.6.0_All.zip
Development Guide
How to use the development kit can refer to the development guide
Http://developer.baidu.com/map/index.php?title=iossdk
Development Package Structure
After unpacking the development package, there are 3 folders
Integrated Development Package
Next create the first Baidu map application, the steps are as follows
- Merge the . A library file for the real machine and simulator
- Add dependent . A,. h,framework,bundle and other resources
- New . mm file
- Modify software unique identities
- Import Primary header file
- Turn on the map engine
- Map Show
1 . Merge the
. A library files of the real machine and simulator
Baidu Map is not open source, only provides a static library file Libbaidumapapi.a, with the real machine and simulator version, respectively, placed in the following two folders:
- Baidumap_iossdk_v2.6.0_lib/libs/release-iphoneos
- Baidumap_iossdk_v2.6.0_lib/libs/release-iphonesimulator
To avoid having to re-add the. A file each time the real machine and the emulator are compiled , you should merge the two . A files into one and enter the instructions on the terminal:
CD/ Here is Baidu map SDK Root path /baidumap_iossdk_v2.1.0_lib/libs
Lipo-create RELEASE-IPHONEOS/LIBBAIDUMAPAPI.A release-iphonesimulator/libbaidumapapi.a-output LIBBAIDUMAPAPI.A
2 . Add the dependent
. A,
. h,
framework,
Bundles and other resources
Add Baidumap_iossdk_v2.1.0_lib the following Inc folder,Mapapi.bundle to the project
Add the merged LIBBAIDUMAPAPI.A library file to the project
Add a dependent framework
Corelocation.framework
Quartzcore.framework
Opengles.framework
Systemconfiguration.framework
Coregraphics.framework
Security.framework(2.1.0 start required)
What's in the final project is:
3 . Create a new
. mm file
The static library is implemented with objectc++ , so you need to ensure that you have at least one . mm suffix source file in your project ( you can rename any. m suffix file to . mm)
4. Modify the software unique identification
The modified software is uniquely identified as the security code when the key was originally requested
5. Import the primary header file
You need to import The main header file of the SDK before using the map
#import "BMapKit.h"
6. turn on the map engine
1 _mapmgr = [[Bmkmapmanager alloc] init]; 2 3 int ret =[_mapmgr start:@ "0f0dd93edfd75399dc65e299305b8490" Generaldelegate:nil]; 4 5 if (ret) {67 MyLog (@ " map engine turned on successfully! " ); 8 9 }
After start, the application key is passed
7. Map Display
Add Bmkmapview to the display map
1 _mapview = [[Bmkmapview alloc] Initwithframe:[uiscreen mainscreen].applicationframe]; 2 3 [Self.view Addsubview:_mapview];
Integration of iOS development Baidu map