百度地图SDK开发者网站: http://lbsyun.baidu.com/index.php?title=iossdk/guide/location
一 申请密钥(安全码):需要 项目名称和bundle ID
网址:http://lbsyun.baidu.com/apiconsole/key
二 注意事项
2工程中至少有一个.mm后缀的源文件(您可以将任意一个.m后缀的文件改名为.mm)
拖入ObjectC++ForBaiduMapBuild.mm文件
3在Xcode的Project -> Edit Active Target -> Build Setting -> Other Linker Flags中添加-ObjC
4自v3.2.0起,百度地图iOS SDK全面支持HTTPS,需要广大开发者导入第三方openssl静态库:libssl.a和libcrypto.a(SDK打好的包存放于thirdlib目录下)
5在info.plist中添加:Bundle display name ,且其值不能为空(Xcode6新建的项目没有此配置,若没有会造成manager start failed)
三 配置开发环境
1.根据需要导入 .framework包: 把BaiduMapAPI_Map.framework等添加到项目中,
2.引入所需的系统库
在您的Xcode工程中引入CoreLocation.framework和QuartzCore.framework、OpenGLES.framework、SystemConfiguration.framework、CoreGraphics.framework、Security.framework、libsqlite3.0.tbd(xcode7以前为 libsqlite3.0.dylib)、CoreTelephony.framework 、libstdc++.6.0.9.tbd(xcode7以前为libstdc++.6.0.9.dylib)。
3.引入所需的第三方openssl库:
添加支持HTTPS所需的penssl静态库:libssl.a和libcrypto.a(SDK打好的包存放于thirdlib目录下)
添加方法: 在 TARGETS->Build Phases-> Link Binary With Libaries中点击“+”按钮,在弹出的窗口中点击“Add Other”按钮,选择libssl.a和libcrypto.a添加到工程中
4环境配置
在TARGETS->Build Settings->Other Linker Flags 中添加-ObjC。
5引入mapapi.bundle资源文件
方法:选中工程名,在右键菜单中选择Add Files to “工程名”…,从BaiduMapAPI_Map.framework||Resources文件中选择mapapi.bundle文件,并勾选“Copy items if needed”复选框,单击“Add”按钮,将资源文件添加到工程中。
四 Hello BaiduMap
1.AppDelegate.m文件中导入
#import <BaiduMapAPI_Map/BMKMapComponent.h>//引入地图功能所有的头文件
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
_mapManager = [[BMKMapManager alloc] init];
BOOL ret = [_mapManager start:@"vV8OMTGeLEPt6Uzbd7TVFm5KGawekzVp" generalDelegate:nil];
if (!ret) {
NSLog(@"manager start failed!");
}
return YES;
}