如何在iOS 6地图上绘制路线?

我想在地图上显示地图和绘制路线。 我的应用程序支持ios 4 plus。 那么我应该如何使用地图来处理iOS 6以及之前的工作。 此外,我想知道sholud我使用自定义mapview在我的应用程序来显示地图和路线,或者我应该使用

[[UIApplication sharedApplication] openURL:] 

我从来没有用户的MapKits 。 所以请提供任何教程。 也让我知道是否有任何可用的党的图书馆。

如果你不想要一个应用内地图。 使用以下内容:

 NSString *destinationAddress = @"Amsterdam"; Class itemClass = [MKMapItem class]; if (itemClass && [itemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)]) { CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder geocodeAddressString:destinationAddress completionHandler:^(NSArray *placemarks, NSError *error) { if([placemarks count] > 0) { MKPlacemark *placeMark = [[MKPlacemark alloc] initWithPlacemark:[placemarks objectAtIndex:0]]; MKMapItem *mapItem = [[MKMapItem alloc]initWithPlacemark:placeMark]; MKMapItem *mapItem2 = [MKMapItem mapItemForCurrentLocation]; NSArray *mapItems = @[mapItem, mapItem2]; NSDictionary *options = @{ MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeDriving, MKLaunchOptionsMapTypeKey: [NSNumber numberWithInteger:MKMapTypeStandard], MKLaunchOptionsShowsTrafficKey:@YES }; [MKMapItem openMapsWithItems:mapItems launchOptions:options]; } else { //error nothing found } }]; return; } else { NSString *sourceAddress = [LocalizedCurrentLocation currentLocationStringForCurrentLanguage]; NSString *urlToOpen = [NSString stringWithFormat:@"http://maps.google.com/maps?saddr=%@&daddr=%@", [sourceAddress stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], [destinationAddress stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlToOpen]]; } 

这将打开地图应用程序并检查它是否是ios5或ios6。

对于ios5我使用LocalizedCurrentLocation从这个posthttp://www.martip.net/blog/localized-current-location-string-for-iphone-apps

对于ios6,我使用CLGeocoder来获取地标,然后用它和当前位置打开地图。

请记住添加CoreLocation.frameworkMapKit.framework