Integration of iOS development Baidu map

Source: Internet
Author: User

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

    1. Merge the . A library file for the real machine and simulator
    2. Add dependent . A,. h,framework,bundle and other resources
    3. New . mm file
    4. Modify software unique identities
    5. Import Primary header file
    6. Turn on the map engine
    7. 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

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.