iOS Development integration Baidu maps the pits that have been trampled (based on xcode7.0/ios9.2)

Source: Internet
Author: User

This 4-step article describes how to integrate Baidu maps into your project:

First step: Create a projectStep Two: Use Cocoapod to import the SDK of Baidu map (pod ' baidumapkit ' #百度地图SDK)Step three: import header files and keys in the PCH file

The secret key is the application in Http://lbsyun.baidu.com/apiconsole/key Baidu open platform.

#define APPKEY @ "Uzyixewpsqphce1ys8wxqik9"

Introduce the bottom header file as needed when using the SDK's classes

#import<BaiduMapAPI_Base/BMKBaseComponent.h>//introduction of all base-related header files #import<BaiduMapAPI_Map/BMKMapComponent.h>//introduce all the header files of the map function #import<BaiduMapAPI_Search/BMKSearchComponent.h>//introduction of Retrieval function All header files #import<BaiduMapAPI_Cloud/BMKCloudSearchComponent.h>//Introduction to the Cloud Retrieval feature all header files #import<BaiduMapAPI_Location/BMKLocationComponent.h>//introduction of positioning function All header files #import<BaiduMapAPI_Utils/BMKUtilsComponent.h>//introduction of all the header files of the calculation tool #import<BaiduMapAPI_Radar/BMKRadarComponent.h>//introduction of all the header files of the perimeter radar function #import< baidumapapi_map/bmkmapview.h>//only the desired single header file is introduced
Fourth Step: Load the map Manager in the APPDELEGATE.M file
-(Bmkmapmanager *) Mapmanager {if(!_mapmanager) {_mapmanager=[[Bmkmapmanager alloc] init]; BOOL ret=[_mapmanager Start:appkey Generaldelegate:nil]; if(!ret) {NSLog (@"Manager Start failed!"); } Else{NSLog (@"Manager Start success!"); }    }    return_mapmanager;}-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {//Override point for customization after application launch.[self mapmanager]; returnYES;}

In this step, we will be able to operate the Baidu map.

However, it is important to note that the following information is output on the console:

Then we follow the requirements step by step, first configure the Bundle display name in the plist file, in fact, this is the information that needs to be configured in the Xcode6, Xcode7 does not require

< Key > Cfbundledisplayname</key><string>$ (product_ NAME)</string>

Run again, the map Manager is loaded successfully, but because iOS9 switch to more secure HTTPS, in order to be able to use the Baidu Map SDK in IOS9, at this time also need to inject ATS

< Key > Nsapptransportsecurity</key><dict>     <key>nsallowsarbitraryloads</key>    <true/></dict>

At this point, although no error, the manager also loaded successfully, the map grid has, but the map details may not appear.

At this point check your key is correct, I have committed once, must be guaranteed to apply key is the security Code and project bundle identifier consistent.

At this point Baidu Map is a successful integration.

Note: The locations described in this article are not configured.

When the app is in front of the background switch, you need to stop the map rendering and OpenGL drawing using the following code:

-(void) Applicationwillresignactive: (uiapplication *) application {    [Bmkmapview willbackground]; // called when the app is about to be in the background, stop everything that calls OpenGL-related operations }-(void) Applicationdidbecomeactive: (uiapplication *) application {    [Bmkmapview Didforeground]; // called when the app resumes foreground state, responds to map rendering and OpenGL-related actions }

iOS Development integration Baidu maps the pits that have been trampled (based on xcode7.0/ios9.2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.