Reputation: 621
I am looking to use the directions from Apple maps in iOS 6 in my app.
I have seen a few examples of how to do this but I am yet to see how this can be done using the longitude and latitude coordinates of a point.
Basically my app is using longitude and latitude to place pins on a map view I would like to get directions to these locations.
Does anyone have an example of this?
Upvotes: 1
Views: 627
Reputation: 6692
You can do this using an MKMapItem
in iOS 6:
(Note that addressDictionary is a dictionary containing keys and values from an Address Book record - see Apple docs for more details)
// Create MKMapPlacemark out of coordinates and addressDictionary
MKPlacemark *placeMark = [[MKPlacemark alloc] initWithCoordinate:coordinate addressDictionary:addressDictionary];
// Create MKMapItem
MKMapItem *destination = [[MKMapItem alloc] initWithPlacemark:placeMark];
// Using iOS6 native maps app
[destination openInMapsWithLaunchOptions:@{MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeDriving}];
Upvotes: 3