iOS 通过调用已安装的地图app进行导航

释放双眼,带上耳机,听听看~!

通过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

人已赞赏
iOS文章

iOS Animation-KeyPath

2020-4-30 2:18:01

iOS文章

ios 文字转语音

2020-4-30 3:33:06

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索