Skip to content

Instantly share code, notes, and snippets.

@wbroek
Created October 2, 2012 12:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wbroek/3818598 to your computer and use it in GitHub Desktop.
Save wbroek/3818598 to your computer and use it in GitHub Desktop.
iOS 6 open Maps with route
Class MKMapItemClass = [MKMapItem class];
if (MKMapItemClass && [MKMapItemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)]) {
CLLocationCoordinate2D endCoord = { 54.0696, 50.3616 };
MKPlacemark *endLocation = [[MKPlacemark alloc] initWithCoordinate:endCoord addressDictionary:nil];
MKMapItem *endingItem = [[MKMapItem alloc] initWithPlacemark:endLocation];
NSMutableDictionary *launchOptions = [[NSMutableDictionary alloc] init];
[launchOptions setObject:MKLaunchOptionsDirectionsModeDriving forKey:MKLaunchOptionsDirectionsModeKey];
[endingItem openInMapsWithLaunchOptions:launchOptions];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment