iOS app jump Baidu Hi-German apple map

Source: Internet
Author: User

Mobile development often uses a number of location-based navigation functions, but for the navigation function is not strong dependence of the application, we directly use the app jump map app can be.

But for app jumps, you first need to set up a whitelist,

In iOS 9 involves the platform client jump, the system automatically to the project Info.plist to detect whether to set the platform scheme, for the platform to be configured, if not configured, will not be able to jump to the platform client, so need to configure scheme list. In this article we need to add Baidu Map and the scheme whitelist of the German map.

How to do this: Add the Lsapplicationqueriesschemes field to the project's info.plist, the type is an array, and then add two item.

The following directly on the main code, online gold is direct navigation, why? Do it all?

-(void) mapbtnclick{if (![       NSString Isnotemptystring:_currentadress]) {[Self.locationmanager startupdatinglocation];   [Sdindicator showinfowithmessage:@ "is positioning, please wait ..."]; } _actionsheet= [[Uiactionsheet alloc] initwithtitle:nil delegate:self cancelbuttontitle:@ "Cancel" DestructiveButtonTitle   : Nil Otherbuttontitles:nil];   Nsmutablearray *mapsarray=[[nsmutablearray alloc] initwithcapacity:0];   _mapsurlarray=[[nsmutablearray alloc] init];   Nsurl * Apple_app = [Nsurl urlwithstring:@ "http://maps.apple.com/"];       if ([[[UIApplication sharedapplication] Canopenurl:apple_app]) {[Mapsarray addobject:@ ' using Apple's own map navigation]; NSString *urlstring=[nsstring stringwithformat:@ "Http://maps.apple.com/?saddr=%f,%f&daddr=%f,%f", _       Strlatitude,_strlongitude,[_model.last_latitude Floatvalue],[_model.last_longitude FloatValue]];   [_mapsurlarray addobject:urlstring];   } nsurl * Baidu_app = [Nsurl urlwithstring:@ "baidumap://"]; if ([[UIApplication sharedapplication] Canopenurl:Baidu_app]) {[Mapsarray addobject:@ "Use Baidu map Navigation"]; NSString *stringurl =[[nsstring stringwithformat:@ "baidumap://map/direction?origin={{My location}}&destination= Latlng:%f,%f|name=%@&mode=driving&coord_type=gcj02 ", [_model.last_latitude floatValue],[_model.last_       Longitude floatvalue],_model.address] stringbyaddingpercentescapesusingencoding:nsutf8stringencoding];          [_mapsurlarray Addobject:stringurl];   } nsurl * Gaode_app = [Nsurl urlwithstring:@ "iosamap://"];       if ([[[UIApplication sharedapplication] Canopenurl:gaode_app]) {[Mapsarray addobject:@ ' using the high-D map navigation]; NSString *urlstring = [[NSString stringwithformat:@] Iosamap://path?sourceapplication=%@&sid=bgvis1&slat=%f &slon=%f&sname=%@&did=bgvis2&dlat=%f&dlon=%f&dname=%@&dev=0&t=0 ", @" Dragon Top Fish Neighbor ", _ Strlatitude,_strlongitude,_currentadress,[_model.last_latitude Floatvalue],[_model.last_longitude floatValue],_ Model.address] StringbyaddingpercentescapesusingencodiNg:nsutf8stringencoding];          [_mapsurlarray addobject:urlstring];          } for (int x=0; x<mapsarray.count; x + +) {[_actionsheet addbuttonwithtitle:[mapsarray objectatindex:x]];   } if (_mapsurlarray.count>0) {[_actionsheet ShowInView:self.view.window];   }else{[Sdindicator showinfowithmessage:@ "recommended that you install the German or Baidu map"]; }  }

Let's say the main points of knowledge

"1"

Use the Canopenurl method to detect if the phone has the appropriate app installed

The method returns a bool value that, when Yes, indicates that the app is installed

"2"

1. Apple comes with map (no need to detect, so no URL Scheme required)
2, Baidu map baidumap://
3. iosamap://Map

Of course, to carry the parameters, according to the rules of each map to pass the value can be

iOS app jump Baidu Hi-German apple map

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.