Plotting System map routes

Source: Internet
Author: User

#import "ViewController.h" #import <MapKit/MapKit.h> #import <CoreLocation/CoreLocation.h> @interface Viewcontroller ()/** geocoding */@property (nonatomic, strong) Clgeocoder *GEOC; @end @implementation Viewcontroller#pragma    Mark-Lazy Loading-(Clgeocoder *) geoc{if (!_GEOC) {_GEOC = [[Clgeocoder alloc] init]; } return _GEOC;} -(void) Touchesbegan: (Nsset<uitouch *> *) touches withevent: (uievent *) event{[SELF.GEOC geocodeaddressstring:@]       Guangzhou "completionhandler:^ (Nsarray<clplacemark *> * _nullable placemarks, Nserror * _nullable error) {//Guangzhou landmark       Clplacemark *GZPL = [Placemarks firstobject]; [SELF.GEOC geocodeaddressstring:@ "Shanghai" completionhandler:^ (Nsarray<clplacemark *> * _Nullable Placemarks,                      Nserror * _nullable error) {//Shanghai landmark Clplacemark *SHPL = [Placemarks firstobject];                             [Self systemnavwithbeginpl:gzpl ENDPL:SHPL];                 }];               }]; }/** * Based on the origin and destination landmarksLike, call the system app to navigate * * @param BEGINCLPL starting point landmark * @param ENDCLPL endpoint landmark */-(void) SYSTEMNAVWITHBEGINPL: (Clplacemark *) BEGINCLPL E NDPL: (Clplacemark *) endclpl{//Call system app to navigate//Map Origin Landmark object Mkplacemark *BEGINPL = [[Mkplacemark alloc] Initwithpl    ACEMARK:BEGINCLPL];        Starting point Mkmapitem *beginitem = [[Mkmapitem alloc] INITWITHPLACEMARK:BEGINPL];    Map end Landmark object Mkplacemark *ENDPL = [[Mkplacemark alloc] INITWITHPLACEMARK:ENDCLPL];            End Mkmapitem *enditem = [[Mkmapitem alloc] INITWITHPLACEMARK:ENDPL];        Starting and ending arrays nsarray *items = @[beginitem, Enditem]; Set map Startup items (Navigation mode: driving, Map type: mixed, whether to show traffic: YES) nsdictionary *dic = @{Mklaunchoptionsdirectionsmodek                          Ey:mklaunchoptionsdirectionsmodedriving, Mklaunchoptionsmaptypekey: @ (Mkmaptypehybrid),        Mklaunchoptionsshowstraffickey: @ (YES),}; Given two points, starting point and end point, then set the startup item and start calling the system app to navigate [MkmaPitem openmapswithitems:items launchoptions:dic];} @end

  

Plotting System map routes

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.