IOS calls Gould, Baidu, apple, and maps to navigate

Due to the size of the package, APP. While navigating, it is not necessary for us to integrate the three party SDK, such as the High German or Baidu, into the project. It’s not only time-consuming and laborious, but there are too many articles on three party APP navigation on the internet. No more details here.

Look at the effect chart first:

IOS calls Gould, Baidu, apple, and maps to navigate
selects the APP for navigation
IOS calls Gould, Baidu, apple, and maps to navigate
apple comes with high moral map
IOS calls Gould, Baidu, apple, and maps to navigate
High German navigation
IOS calls Gould, Baidu, apple, and maps to navigate
Baidu navigation

First we need to configure some white list. Following screenshot:

IOS calls Gould, Baidu, apple, and maps to navigate
white list

Info.plist add LSApplicationQueriesSchemes, set to Array. Add the corresponding white list;

Here to the High German, Baidu, for example, High German: iosamap, Baidu: baidumap; set up, you can begin the code section.

Code part of the specific steps are as follows. Students who don’t want to watch, Download demo directly. The demo implementation is written in both the MapTool tool classes. You can use the following method directly.

/ * *

Call three party navigation

@param coordinate latitude and longitude

The name displayed on the @param name map

@param tager current controller

* /

– – (void) navigationActionWithCoordinate: (CLLocationCoordinate2D), coordinate, WithENDName: (NSString*), name, tager: (UIViewController*), tager;

To navigation must first know the latitude and longitude of end point.

Import #import< MapKit/MapKit.h>.

Define a CLLocationCoordinate2D property that contains the latitude and longitude of your destination.

@property (nonatomic, assign) CLLocationCoordinate2D coordinate;

The assumed position is self.coordinate=CLLocationCoordinate2DMake (34.72113.92);

Take your seat and you’ll be able to navigate

The first is Apple’s High German simplified version of the map:

That’s all the code

MKMapItem *currentLocation = [MKMapItem mapItemForCurrentLocation];

MKMapItem *tolocation = [[MKMapItem, alloc], initWithPlacemark:[[MKPlacemark, alloc], initWithCoordinate:coordinate, addressDictionary:nil]];

Tolocation.name = map_title;

[MKMapItem openMapsWithItems:@[currentLocation, tolocation]launchOptions:@{MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeDriving MKLaunchOptionsShowsTrafficKey:[NSNumber, numberWithBool:YES]}];

High moral map:

NSString *urlsting =[[NSString stringWithFormat:@ iosamap://navi sourceApplication= &amp? BackScheme=; & lat=%f& lon=%f& dev=0& style=2, coordinate.latitude, coordinate.longitude]stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];

[[UIApplicationsharedApplication]openURL:[NSURL URLWithString:urlsting]];

Baidu Maps:

NSString *urlsting =[[NSString stringWithFormat:@ baidumap://map/direction origin={{}}&amp my position?; destination=latlng:%f,%f|name= to & mode=driving& coord_type=gcj02, coordinate.latitude, coordinate.longitude] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlsting]];

Here, the three party App navigation has been completed. Demo is up there. No friends, look here, Demo Download