我想知道是否可以在 iOS 6 上的 MKMapView 中创建导航路线,而不是打开内置的 Maps 应用程序?
我用谷歌搜索但没有找到任何答案。
这是我现在使用的代码(打开内置地图应用程序):
-(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 按钮上方)时,我想通过转弯路线进行转弯:
谢谢您的帮助。