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];}