組み込みのマップアプリケーションを開く代わりに、iOS 6のMKMapView内にナビゲーションルートを作成できるかどうか疑問に思いましたか?
グーグルで検索しましたが、答えが見つかりませんでした。
これは私が現在使用しているコードです(つまり、組み込みのマップアプリを開いています)。
-(IBAction) navigation
{
if (SYSTEM_VERSION_LESS_THAN(@"6.0"))
{
NSString *destinationString = @"Afek, Israel";
NSString *url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%f,%f&daddr=%@",wedMapView.userLocation.coordinate.latitude,wedMapView.userLocation.coordinate.longitude, destinationString];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}
else
{
Class mapItemClass = [MKMapItem class];
if (mapItemClass && [mapItemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)])
{
double latitude = 32.83431728836292;
double longitude = 35.128666162490845;
MKPlacemark *placemark = [[[MKPlacemark alloc] initWithCoordinate:CLLocationCoordinate2DMake(latitude, longitude) addressDictionary:nil] autorelease];
//[mapItem setName:@"Name of your location"];
// Create a map item for the geocoded address to pass to Maps app
MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
[mapItem setName:@"שמורתה, קיבוץ אפק"];
// Set the directions mode to "Driving"
// Can use MKLaunchOptionsDirectionsModeWalking instead
NSDictionary *launchOptions = @{MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeDriving};
// Get the "Current User Location" MKMapItem
MKMapItem *currentLocationMapItem = [MKMapItem mapItemForCurrentLocation];
// Pass the current location and destination map items to the Maps app
// Set the direction mode in the launchOptions dictionary
[MKMapItem openMapsWithItems:@[currentLocationMapItem, mapItem] launchOptions:launchOptions];
};
}
}
そしてこれは私が持っているMKMapViewです私が青い地図ボタン(Wazeボタンの上)を押したときにターンバイターン方式で作りたいです:
助けてくれてありがとう。