The Apple system itself comes with a map app, but the function is not very powerful, but some simple navigation functions can be done, the following paste my code
////VIEWCONTROLLER.M//System App Navigation////Created by Zhang Xiuqing on 15/5/4.//Copyright (c) 2015 Zhang Xiuqing. All rights reserved.//#import "ViewController.h"#import<MapKit/MapKit.h>@interfaceViewcontroller ()/** * Input starting point*/@property (nonatomic,strong) Uitextfield*Starttf;/** * Enter the end point*/@property (nonatomic,strong) Uitextfield*ENDTF;/** * Start navigation button*/@property (nonatomic,strong) UIButton*Navigatebutton;/** * Geo encoder*/@property (nonatomic,strong) Clgeocoder*Geocoder;@end@implementationViewcontroller#pragmaMark-Lazy Loading-(Clgeocoder *) geocoder{if(!_geocoder) {_geocoder=[[Clgeocoder alloc]init]; } return_geocoder;}- (void) viewdidload {[Super viewdidload]; [Self initui];}#pragmaMark-Initialize ui-(void) initui{_starttf= [[Uitextfield alloc]initwithframe:cgrectmake ( -, -, Max, -)]; _starttf.borderstyle=Uitextborderstyleroundedrect; _starttf.placeholder=@"begin"; [Self.view Addsubview:_starttf]; _ENDTF= [[Uitextfield alloc]initwithframe:cgrectmake ( -, Max, Max, -)]; _endtf.borderstyle=Uitextborderstyleroundedrect; _endtf.placeholder=@"End"; [Self.view ADDSUBVIEW:_ENDTF]; _navigatebutton=[UIButton Buttonwithtype:uibuttontypesystem]; _navigatebutton.frame= CGRectMake ( -, $, -, -); [_navigatebutton settitle:@"Start"Forstate:uicontrolstatenormal]; [_navigatebutton addtarget:self Action: @selector (Startnavigation) forcontrolevents:uicontroleventtouchupinside]; [Self.view Addsubview:_navigatebutton];}#pragmaMark-Start Navigation-(void) startnavigation{[Self.geocoder geocodeAddressString:self.startTF.text Completionhandler:^ (Nsarray *placemarks, Nserror *error) { /** * Get initial location information*/ if(Placemarks.count = =0) { return ; } Clplacemark*startclplacemark =[Placemarks Lastobject]; [Self.geocoder geocodeAddressString:self.endTF.text Completionhandler:^ (Nsarray *placemarks, Nserror *error) { /** * Get the end location information*/ if(Placemarks.count = =0) { return ; } Clplacemark*endclplacemark =[Placemarks Lastobject]; //Start Navigation[self Navigatewithstartclplacemark:startclplacemark endclplacemark:endclplacemark]; }]; }];}//Start Navigation-(void) Navigatewithstartclplacemark: (Clplacemark *) Startclplacemark Endclplacemark: (Clplacemark *) endclplacemark{Mkplacemark*startmkplacemark =[[Mkplacemark Alloc]initwithplacemark:startclplacemark]; Mkplacemark*endmkplacemark =[[Mkplacemark Alloc]initwithplacemark:endclplacemark]; Mkmapitem*startitem =[[Mkmapitem Alloc]initwithplacemark:startmkplacemark]; Mkmapitem*enditem =[[Mkmapitem Alloc]initwithplacemark:endmkplacemark]; Nsmutabledictionary*dict =[Nsmutabledictionary dictionary]; Dict[mklaunchoptionsmaptypekey]= @ (Mkmaptypestandard);//Map ModeDict[mklaunchoptionsdirectionsmodekey] = mklaunchoptionsdirectionsmodedriving;//navigation mode (walk/drive)[Mkmapitem Openmapswithitems:@[startitem,enditem] launchoptions:dict];//Open System map start navigation}@end
Navigate---by Zhang Xiuqing using the system app