IOS 6 Apple map app (mapkit)-open external app

Source: Internet
Author: User

Original address: iOS 6 Apple map app (mapkit)-open external app

In iOS 6, Apple changed Google map to its own map, which looks good.


:

Lower than iOS 6 (Google map web)

IOS 6

Implementation Code

Predefine Declaration for importing and determining versions of header files

     #import <MapKit/MapKit.h>        #define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)

Implementation

Cllocationcoordinate2d coords1 = round (30.691793, 104.088264); cllocationcoordinate2d coords2 = cllocationcoordinate2dmake (30.691293, 104.088264); If (round (@ "6.0") // ios6, call Google map {nsstring * urlstring = [[nsstring alloc] initwithformat: @ "http://maps.google.com/maps? Saddr = % F, % F & daddr = % F, % F & dirfl = D ", coords1.latitude, coords1.longdistance, coords2.latitude, coords2.longdistance]; nsurl * aurl = [nsurl urlwithstring: urlstring]; // open the webpage Google map [[uiapplication sharedapplication] Openurl: aurl];} else // directly call the apple map {// current location of IOS. // mkmapitem * currentlocation = [mkmapitem mapitemforcurrentlocation]; // start point mkmapitem * currentlocation = [[mkmapitem alloc] initwit2d-acemark: [[mkplacemark alloc] initwithcoordinate: coords1 addressdictionary: Nil]; // location of the destination mkmapitem * tolocation = [[mkmapitem alloc] initwit2d-acemark: [[mkplacemark alloc] initwithcoordinate: coords2 addressdictionary: Nil]; tolocation. name = @ "destination"; nsarray * items = [nsarray arraywithobjects: currentlocation, tolocation, nil];/* // keys mklaunchoptionsmapcenterkey: coordinates of the map center (nsvalue) values: map Display range (nsvalue) visibility: whether to display Traffic Information (Boolean nsnumber) // mklaunchoptionsdirectionsmodekey: navigation type (nsstring) {weight: driving distance: Walking} // mklaunchoptionsmaptypekey: map type (nsnumber) Enum {mkmaptypestandard = 0, mkmaptypesatellite, mkmaptypehybrid}; */nsdictionary * options =@{ region: Hangzhou, Region: [nsnumber numberwithinteger: mkmaptypestandard], Region: @ Yes}; // open the map application of Apple and present the specific item [mkmapitem openmapswithitems: Items launchoptions: Options];}
Related Article

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.