Maps navigation integration in iOS 6

From iOS 6 SDK every developer can add the Maps Navigation Step-by-Step feature to their apps using a very simple code. Please note you will need to add the Mapkit and the AddressBook frameworks to your project.

// Creating the placemark for the destination point
CLLocationCoordinate2D coords = 
CLLocationCoordinate2DMake(40.74835, -73.984911);

NSDictionary *address = @{
(NSString *)kABPersonAddressStreetKey: @"350 5th Avenue",
(NSString *)kABPersonAddressCityKey: @"New York",
(NSString *)kABPersonAddressStateKey: @"NY",
(NSString *)kABPersonAddressZIPKey: @"10118",
(NSString *)kABPersonAddressCountryCodeKey: @"US"

MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:coords

MKMapItem *itemDestination = [[MKMapItem alloc]initWithPlacemark:placemark];
MPMapItem *itemOrigin = [MKMapItem mapItemForCurrentLocation];

// Route points
NSArray *mapItem = @[itemOrigin, itemDestination];

NSDictionary *options = @{
[NSNumber numberWithInteger:MKMapTypeStandard],

// Open the Maps app with the Step-by-step directions
[MKMapItem openMapsWithItems:mapItems launchOptions:options];

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>