- (void)openMapsWithLatitude:(double)latitude longitude:(double)longitude
{
// openMapsWithItems が定義されていれば実行
Class itemClass = [MKMapItem class];
if (itemClass && [itemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)]) {
CLLocation *location = [[CLLocation alloc] initWithLatitude:latitude longitude:longitude];
// 緯度経度から逆変換して位置情報取得
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
MKPlacemark *placemark = [[MKPlacemark alloc] initWithPlacemark:[placemarks objectAtIndex:0]];
MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
NSArray *mapItems = [NSArray arrayWithObjects:mapItem, nil];
// 歩いた場合の経路を表示するオプション
NSDictionary *launchOptions = [NSDictionary dictionaryWithObjectsAndKeys:MKLaunchOptionsDirectionsModeWalking, MKLaunchOptionsDirectionsModeKey, nil];
[MKMapItem openMapsWithItems:mapItems launchOptions:launchOptions];
}];
}
}
こんな感じで。