Skip to content

Instantly share code, notes, and snippets.

@NikolaKirev
Last active December 16, 2015 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NikolaKirev/5362672 to your computer and use it in GitHub Desktop.
Save NikolaKirev/5362672 to your computer and use it in GitHub Desktop.
Map Directions tutorial
Class itemClass = [MKMapItem class];
if (itemClass && [itemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)]) {
MKMapItem *currentLocationItem = [MKMapItem mapItemForCurrentLocation];
MKPlacemark *place = [[MKPlacemark alloc] initWithCoordinate:CLLocationCoordinate2DMake([natObject.latitude doubleValue], [natObject.longitude doubleValue]) addressDictionary:nil];
MKMapItem *destinamtionLocItem = [[MKMapItem alloc] initWithPlacemark:place];
destinamtionLocItem.name = [natObject name];
NSArray *mapItemsArray = @[currentLocationItem, destinamtionLocItem];
NSDictionary *dictForDirections = @{MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving};
[MKMapItem openMapsWithItems:mapItemsArray launchOptions:dictForDirections];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment