Last active
December 16, 2015 02:29
-
-
Save NikolaKirev/5362672 to your computer and use it in GitHub Desktop.
Map Directions tutorial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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