- (void)aNaviWithCoordinate:(CLLocationCoordinate2D)coordinate andWithMapTitle:(NSString*)map_title{
//直接导航
// NSString *urlsting =[[NSString stringWithFormat:@"iosamap://navi?sourceApplication= &backScheme= &lat=%f&lon=%f&dev=1&style=1",coordinate.latitude,coordinate.longitude]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//到地图导航
NSString *urlString = [[NSString stringWithFormat:@"iosamap://path?sourceApplication=ApplicationName&sid=BGVIS1&slat=%f&slon=%f&sname=当前位置&did=BGVIS2&dlat=%f&dlon=%f&dname=%@&dev=0&m=0&t=0", self.barLat
, self.barLon, coordinate.latitude, coordinate.longitude, map_title]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
// [CGOpenUrlTool openUrl:[NSURL URLWithString:urlString]];
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlString]];
}
////唤醒苹果自带导航
- (void)appleNaiWithCoordinate:(CLLocationCoordinate2D)coordinate andWithMapTitle:(NSString*)map_title{
MKMapItem*currentLocation = [MKMapItemmapItemForCurrentLocation];
MKMapItem *tolocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark alloc] initWithCoordinate:coordinate addressDictionary:nil]];
tolocation.name= map_title;
[MKMapItem openMapsWithItems:@[currentLocation,tolocation] launchOptions:@{MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeDriving,
MKLaunchOptionsShowsTrafficKey:[NSNumbernumberWithBool:YES]}];
}
- (void)baiduNaviWithCoordinate:(CLLocationCoordinate2D)coordinate andWithMapTitle:(NSString*)map_title{
NSString *urlsting =[[NSString stringWithFormat:@"baidumap://map/direction?origin={{我的位置}}&destination=latlng:%f,%f|name=目的地&mode=driving&coord_type=gcj02",coordinate.latitude,coordinate.longitude] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlsting]];
}
网友评论