iOS Baidu Map Explore

Source: Internet
Author: User

After the new project, several preparations are:

1. A file in the project is set to. mm suffix

2. Add-OBJC to other Linker flags, Build-linking

3, set the link path of the static library, add your static library directory to the library search paths, search Path----- such as "$ (srcroot)/. /libs/release$ (Effective_platform_name) ", $ (SRCROOT) macro represents your project file directory, $ (effective_platform_name) The macro represents whether the current configuration is OS or simulator

4, Framework:CoreLocation.framework and Quartzcore.framework, Opengles.framework, Systemconfiguration.framework, Coregraphics.framework, Security.framework

5, since the iOS SDK v2.5.0, in order to iOS8 positioning ability to do compatible, made the corresponding changes, developers in the process of attention to the following matters: Need to be added in Info.plist (the following two select one, two are added by default using Nslocationwheninuseusagedescription):

Nslocationwheninuseusagedescription, allowing the GPS description to be used in the foreground

Nslocationalwaysusagedescription, allow permanent use of GPS description

The first thing to do is add the appdelegate inside

Bmkmapmanager
-(BOOL) Application: (UIApplication *) application   didfinishlaunchingwithoptions: (nsdictionary *) launchOptions {       //To use Baidu Map, please first start baidumapmanager      _mapmanager = [[Bmkmapmanager alloc]init];   If you want to focus on network and authorization authentication events, set the     generaldelegate parameter      BOOL ret = [_mapmanager start:@ "Enter your authorization key here"  Generaldelegate: NIL];      if (!ret) {          NSLog (@ "manager start failed!");      }  ADD the navigation controller ' s view to the window and display.      [Self.window AddSubview:navigationController.view];      [Self.window makekeyandvisible];     return YES;  }

Positioning:

@interface Viewcontroller () <bmkmapviewdelegate,bmkcloudsearchdelegate,bmklocationservicedelegate>{    bmkmapview* Mapview;    bmkcloudsearch* Search;    bmklocationservice* location;}
-(void) viewdidload {[Super viewdidload];    CGRect rect = CGRectMake (0, 0, 320, 400);    Mapview = [[Bmkmapview alloc] initwithframe:rect];    [Self.view Addsubview:mapview];    Mapview.showsuserlocation= YES;    Searching for search = [[Bmkcloudsearch alloc] init];    Search.delegate = self;    service location = [[Bmklocationservice alloc] init];    Location.delegate = self;    [Location Startuserlocationservice];    Mapview.showsuserlocation = NO;    Mapview.usertrackingmode = bmkusertrackingmodefollowwithheading;    Mapview.showsuserlocation = YES;    Search button uibutton* btsearch = [UIButton buttonwithtype:uibuttontypecustom];    [Btsearch settitle:@ "search" forstate:uicontrolstatenormal];    [Btsearch addtarget:self Action: @selector (Clicksearch:) forcontrolevents:uicontroleventtouchupinside];    [Btsearch setframe:cgrectmake (0, 400, 320, 80)];    [Btsearch Settintcolor:[uicolor Whitecolor];    [Btsearch Settitlecolor:[uicolor Blackcolor] forstate:uicontrolstatenormal]; [Self.view ADdsubview:btsearch];}    -(void) Viewwillappear: (BOOL) animated{[Mapview viewwillappear]; Mapview.delegate = self;}    -(void) Viewwilldisappear: (BOOL) animated{[Mapview viewwilldisappear]; Mapview.delegate = nil;}

Mapview Proxy implementations:

-(void) didupdateuserheading: (bmkuserlocation *) userlocation{    [Mapview updatelocationdata:userlocation];} Processing location coordinates update-(void) Didupdateuserlocation: (bmkuserlocation *) userlocation{    [Mapview updatelocationdata: Userlocation];}

Record these first, do not have to check every time Baidu egg pain document.

  

  

iOS Baidu Map Explore

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.