viewcontroller.m// app Self-guided//// created by wup on 15/ 5/23.// copyright (c) 2015 year apple. all rights reserved.//#import "ViewController.h" #import <MapKit/MapKit.h> @interface ViewController () @property (Nonatomic,strong) CLGeocoder *geo; @end @implementation viewcontroller- (void) Viewdidload { [super viewdidload]; // do any additional setup after loading the view, typically from a nib.// cllocationmanager *clmgr = [[cllocationmanager alloc] init];// [clmgr requestalwaysauthorization]; // mkmapview *mv = [[mkmapview alloc] initwithframe:self.view.bounds];// [self.view addsubview:mv]; [self.geo geocodeaddressstring:@ "Lijiang" completionhandler:^ (Nsarray *placemarks, nserror *error) { //get to the beginning of the mkplacemark mkplacemark *startplace = [[mkplacemark alloc] initWithPlacemark:[placemarks firstObject]]; //waiting to get to the beginning of the placemarks after getting the end of the Placemarks,block callback delay problem [self.geo geocodeaddressstring:@ "Beijing" completionhandler:^ (NSArray *placemarks, nserror *error) { /** the mkplacemark,mkplacemark that gets to the end point is the subclass of Clplacemark. */ mkplacemark *endplace = [[mkplacemark alloc] initWithPlacemark:[placemarks firstObject]]; /** convert Mkplacemark to Mkmapitem so that it can be put into the item array */ mkmapitem *startitem = [[mkmapitem alloc ] initWithPlacemark:startPlace]; mkmapitem *enditem = [[ mkmapitem alloc ] initwithplacemark:endplace]; nsarray * item = @[startitem ,enditem]; //setting the parameters of the dictionary store navigation nsmutabledictionary *md = [ nsmutabledictionary dictionary]; md[mklaunchoptionsdirectionsmodekey] = mklaunchoptionsdirectionsmodedriving; md[MKLaunchOptionsMapTypeKey] = [NSNumber Numberwithinteger:mkmaptypehybrid]; /** * calls the app with its own navigation, it needs to pass in an array and a dictionary, and put the mkmapitem, in the array. dictionary to put the corresponding key value mklaunchoptionsdirectionsmodekey Open Navigation mode MKLaunchOptionsMapTypeKey Map Mode mkmaptypestandard = 0, mkmaptypesatellite, mkmaptypehybrid // Navigation mode mklaunchoptionsdirectionsmodedriving Drive; MKLaunchOptionsDirectionsModeWalking Walking; */#warning In fact, all the code is for the following sentence, open the system comes with a gold map and perform certain actions, The parameters inside the launchoptions specify which actions to do [mkmapitem openMapsWithItems:item launchOptions:md]; }]; &NBSP;&NBSP;&NBSP;}];&NBSP,} #pragma mark - Super lazy load-(clgeocoder *) geo{ if (!_geo) { _geo = [[CLGeocoder alloc] init]; } return _geo;} @end
IOS 8 using the system to bring your own navigation