在IOS6.0系统后,苹果自己绑定了自家的地图包,因此兼容IOS5.0与IOS6.0地图导航,需要分两个步骤
1.首先#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion]
compare:v options:NSNumericSearch] == NSOrderedAscending)
用来获取手机的系统,判断系统是多少
2.地图导航代码
if (SYSTEM_VERSION_LESS_THAN(@"6.0"))
{//6.0以下,调用googleMap
NSLog(@"6.0以下,调用googleMap");
//注意经纬度不要写反了
NSString *
loadString=[NSString stringWithFormat:@"http://maps.google.com/maps?saddr=%@,%@&daddr=%@,%@",self.myPositionWeiduString,self.myPositionJinduString,yweiduString,xjinduString];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:loadString]];
}else{
CLLocationCoordinate2D to;
//要去的目标经纬度
to.latitude = [yweiduString floatValue];
to.longitude = [xjinduString floatValue];
MKMapItem *currentLocation = [MKMapItem mapItemForCurrentLocation];//调用自带地图(定位)
//显示目的地坐标。画路线
MKMapItem *toLocation
= [[MKMapItem alloc] initWithPlacemark:[[[MKPlacemark alloc] initWithCoordinate:toaddressDictionary:nil] autorelease]];
toLocation.name = self.shopNameStirng;
[MKMapItem openMapsWithItems:[NSArray arrayWithObjects:currentLocation,
toLocation, nil]
launchOptions:[NSDictionary dictionaryWithObjects:[NSArrayarrayWithObjects:MKLaunchOptionsDirectionsModeDriving,
[NSNumber numberWithBool:YES], nil]
forKeys:[NSArrayarrayWithObjects:MKLaunchOptionsDirectionsModeKey, MKLaunchOptionsShowsTrafficKey, nil]]];
[toLocation release];
}