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?
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}];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.