通过url跳转到已经安装的手机app中进行导航 记得查看经纬度编码哦~
- 高德
NSURL *aMapScheme = [NSURL URLWithString:@"iosamap://"];
BOOL canOpenAMap = [[UIApplication sharedApplication] canOpenURL:aMapScheme];
NSURL *myLocationScheme = [NSURL URLWithString:[NSString stringWithFormat:@"iosamap://navi?sourceApplication=applicationName&lat=%f&lon=%f&dev=0&style=2",lat,lon]];
if ([[UIDevice currentDevice].systemVersion integerValue] >= 10) {
//iOS10以后,使用新API
[[UIApplication sharedApplication] openURL:myLocationScheme options:@{} completionHandler:^(BOOL success) {
NSLog(@"scheme调用结束");
}];
} else { //iOS10以前,使用旧API
[[UIApplication sharedApplication] openURL:myLocationScheme];
}
高德官方地址: https://lbs.amap.com/api/amap-mobile/guide/ios/navi
- 百度
NSURL *bMapScheme = [NSURL URLWithString:@"baidumap://"];
BOOL canOpenBMap = [[UIApplication sharedApplication] canOpenURL:bMapScheme];
NSURL *myLocationScheme = [NSURL URLWithString:[NSString stringWithFormat:@"baidumap://map/navi?location=%f,%f&coord_type=gcj02",lat,lon]];
if ([[UIDevice currentDevice].systemVersion integerValue] >= 10) {
//iOS10以后,使用新API
[[UIApplication sharedApplication] openURL:myLocationScheme options:@{} completionHandler:^(BOOL success) {
NSLog(@"scheme调用结束");
}];
} else { //iOS10以前,使用旧API
[[UIApplication sharedApplication] openURL:myLocationScheme];
}
百度的官方地址: http://lbsyun.baidu.com/index.php?title=uri/api/ios#service-page-anchor7
- 腾讯
BOOL canOpenQQMap = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"qqmap://"]];
NSString *urlStr = [NSString stringWithFormat:@"qqmap://map/routeplan?type=drive&fromcoord=CurrentLocation&tocoord=%f,%f",lat,lon];
NSURL *r = [NSURL URLWithString:urlStr];
[[UIApplication sharedApplication] openURL:r];
UIAlertAction *QQAction = [UIAlertAction actionWithTitle:@"腾讯地图" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSString *urlStr = [NSString stringWithFormat:@"qqmap://map/routeplan?type=drive&fromcoord=CurrentLocation&tocoord=%f,%f",lat,lon];
NSURL *r = [NSURL URLWithString:urlStr];
[[UIApplication sharedApplication] openURL:r];
}];
腾讯的官方地址: https://lbs.qq.com/uri_v1/guide-mobile-navAndRoute.html