сначала необходимо в файле controller.h просмотреть запись
- (IBAction)startWithOnePlacemark:(id)sender;
- (IBAction)startWithMultiplePlacemarks:(id)sender;
- (IBAction)startInDirectionsMode:(id)sender;
, затем в Viewcontroller.m
- (IBAction)startWithOnePlacemark:(id)sender
{
CLLocationCoordinate2D bigBenLocation = CLLocationCoordinate2DMake(51.50065200, -0.12483300);
MKPlacemark *bigBenPlacemark = [[MKPlacemark alloc] initWithCoordinate:bigBenLocation addressDictionary:nil];
MKMapItem *bigBenItem = [[MKMapItem alloc] initWithPlacemark:bigBenPlacemark];
bigBenItem.name = @"Big Ben";
[bigBenItem openInMapsWithLaunchOptions:nil];
// Note: use initWithPlacemark: to initialize with CLPlacemark
}
- (IBAction)startWithMultiplePlacemarks:(id)sender
{
CLLocationCoordinate2D bigBenLocation = CLLocationCoordinate2DMake(51.50065200, -0.12483300);
MKPlacemark *bigBenPlacemark = [[MKPlacemark alloc] initWithCoordinate:bigBenLocation addressDictionary:nil];
MKMapItem *bigBenItem = [[MKMapItem alloc] initWithPlacemark:bigBenPlacemark];
bigBenItem.name = @"Big Ben";
CLLocationCoordinate2D westminsterLocation = CLLocationCoordinate2DMake(51.50054300, -0.13570200);
MKPlacemark *westminsterPlacemark = [[MKPlacemark alloc] initWithCoordinate:westminsterLocation addressDictionary:nil];
MKMapItem *westminsterItem = [[MKMapItem alloc] initWithPlacemark:westminsterPlacemark];
westminsterItem.name = @"Westminster Abbey";
NSArray *items = [[NSArray alloc] initWithObjects:bigBenItem, westminsterItem, nil];
[MKMapItem openMapsWithItems:items launchOptions:nil];
}
- (IBAction)startInDirectionsMode:(id)sender
{
CLLocationCoordinate2D bigBenLocation = CLLocationCoordinate2DMake(51.50065200, -0.12483300);
MKPlacemark *bigBenPlacemark = [[MKPlacemark alloc] initWithCoordinate:bigBenLocation addressDictionary:nil];
MKMapItem *bigBenItem = [[MKMapItem alloc] initWithPlacemark:bigBenPlacemark];
bigBenItem.name = @"Big Ben";
CLLocationCoordinate2D westminsterLocation = CLLocationCoordinate2DMake(51.50054300, -0.13570200);
MKPlacemark *westminsterPlacemark = [[MKPlacemark alloc] initWithCoordinate:westminsterLocation addressDictionary:nil];
MKMapItem *westminsterItem = [[MKMapItem alloc] initWithPlacemark:westminsterPlacemark];
westminsterItem.name = @"Westminster Abbey";
NSArray *items = [[NSArray alloc] initWithObjects:bigBenItem, westminsterItem, nil];
NSDictionary *options = @{MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeWalking};
[MKMapItem openMapsWithItems:items launchOptions:options];
}
добавить Mapkit, AddressBook, CoreLocation Framework