iOS 在 程序内调用手机上安装的地图软件进行导航
// 需求是需要用户 能从 所在位置 到 附近的健身房的 路线, 然而,就一个需求,不值当的添加一个地图, 就用调用手机上第三方地图软件, 什么高德, 百度, 腾讯, iOS 原生地图都可以, 如果手机上什么地图都没有, 还有原生的 地图, 如果连原生的地图都删除了, 呵呵, 那我就不管了, 开玩笑, 如果连原生地图都删除了, 会跳转到 appStore 下载, 苹果自带的软件, 不会删除, 只是把图标隐藏而已, 下载非常快, 几秒即可. 不影响什么
// 进入正题
// 首先 添加白名单, 这是 必须的, 否则不能跳转, 添加在这里
LSApplicationQueriesSchemes
baidumap//百度
iosamap// 高德
comgooglemaps//谷歌
// 谷歌经我亲测, 在中国已废, 打开没有内容, 不用也罢
重点是打开的代码
iOS 原生地图
//当前的位置
MKMapItem *currentLocation = [MKMapItem mapItemForCurrentLocation];
//目的地的位置
MKMapItem *toLocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark alloc] initWithCoordinate:CLLocationCoordinate2DMake(latitude, longitude) addressDictionary:nil]];
toLocation.name = name;
NSArray *items = [NSArray arrayWithObjects:currentLocation, toLocation, nil];
NSDictionary *options = @{ MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeDriving, MKLaunchOptionsMapTypeKey: [NSNumber numberWithInteger:MKMapTypeStandard], MKLaunchOptionsShowsTrafficKey:@YES };
//打开苹果自身地图应用,并呈现特定的item
[MKMapItem openMapsWithItems:items launchOptions:options];
// 百度地图
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"baidumap://"]]) {
UIAlertAction * baiduAction = [UIAlertAction actionWithTitle:@"百度地图" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSString *urlString = [[NSString stringWithFormat:@"baidumap://map/direction?origin={{我的位置}}&destination=latlng:%f,%f|name=%@&mode=driving&coord_type=gcj02",latitude, longitude,name]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
}];
}
// 高德地图
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"iosamap://"]]) {
UIAlertAction * gaodeAction = [UIAlertAction actionWithTitle:@"高德地图" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSString *urlString = [[NSString stringWithFormat:@"iosamap://navi?sourceApplication=%@&backScheme=%@&lat=%f&lon=%f&dev=0&style=2",@"一七健康",@"yiqihealth",latitude, longitude] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
}];
}
运行之后, 完美
iOS 在 程序内调用手机上安装的地图软件进行导航的更多相关文章
- Android 调用手机上第三方百度地图并传值给地图
//移动APP调起Android百度地图方式举例 Intent intent = null; try { // intent = Intent.getIntent("intent://map ...
- 微信小程序开发常见的拉起外部地图软件进行导航的功能
<view class="dh" bindtap="mapNavigation" data-addr="{{address}}"> ...
- 安卓手机上安装 谷歌 play 商店
安卓手机上安装 谷歌 play 商店 安卓(Android)就是现在流行的智能手机系统,它是由Google公司和开放手机联盟领导及开发.由于安卓系统的底层代码(AOSP)是开源的,以GPL和Apach ...
- 如何通过wifi在android手机上安装调试应用
如何通过wifi在android手机上安装调试应用 1. 首先还是要打开手机的usb调试选项,并通过usb线连接手机.2. 然后执行“adb tcpip 5555”,把adb从usb模式切换到tcpi ...
- Android 手机上安装并运行 Ubuntu 12.04
ubuntu.sh脚本的原地址变动了,导致下载不了,现在更新了网盘地址.小技巧:遇到一些下载失效的时候可以试一试p2p下载工具(如 easyMule.迅雷等)试一试,说不定有人分享过~* —————— ...
- Android 在同一个手机上安装多个同样的apk,便于调试
Android studio 在同一个手机上安装多个同样的apk 原文地址:http://yj.itrydo.com/posts/iKJryXL9zkfSGRTZk 先看效果: 1.在我使用ecsli ...
- Android 在同一个手机上安装多个相同的apk,便于调试
Android studio 在同一个手机上安装多个相同的apk 原文地址:http://yj.itrydo.com/posts/iKJryXL9zkfSGRTZk 先看效果: 1.在我使用ecsli ...
- <转>iOS应用程序内使用IAP/StoreKit付费、沙盒(SandBox)测试、创建测试账号流程!
原文地址:http://blog.csdn.net/xiaominghimi/article/details/6937097 //——2012-12-11日更新 获取"产品付费数量等于0 ...
- 【转】详解iOS应用程序内使用IAP/StoreKit付费、沙盒(SandBox)测试、创建测试账号流程
http://blog.csdn.net/xiaominghimi/article/details/6937097 //——2012-12-11日更新 获取"产品付费数量等于0这个问题& ...
随机推荐
- Jenkins和pipeline
Jenkins https://jenkins.io/index.html The leading open source automation server, Jenkins provides hu ...
- treap基本操作
利用rand保持堆的特性 const int N=; int ls[N],rs[N],v[N],p[N],cnt[N],siz[N]; // 权值 优先级 inline void update(int ...
- dubbo 初探
dubbo官网:http://dubbo.io Dubbo背景和简介(摘自 http://blog.csdn.net/noaman_wgs/article/details/70214612) Dubb ...
- 007_Reverse Integer
###solution1####small data # def reverse(x): # res=[] # t=0 # p=1 #记录位数 # y=x # if x<0: # x=-x # ...
- python-文件读写操作
打开文件: f=open('test.txt',mode='r',encoding='utf-8') 参数1 文件名,若非当前路径,需指出具体路径 参数2 mode: 文件打开模式 r ...
- frame与iframe的区别及基本用法
frame 和 iframe 的区别 1.frame 不能脱离 frameset 单独使用,iframe 可以: 2.frame 不能放到body中,否则将无法显示: 3.iframe 也可以嵌套在f ...
- CDH5.12安装检查Inspector failed on the following hosts...
1 安装检查报错 2 原因是因为自己的文件没有全部同步过去 hadoop003文件下面缺少了cm文件夹的内容 3 cp过去 scp -r cm root@hadoop003:/var/www/html ...
- day 10 - 2 函数练习
1.写函数 接收 n 个数字 求这些参数数字的和 def sum_func(*args): total = 0 for i in args: total += i return total prin ...
- CentOS6.8合并DVD1和DVD2作为本地yum源
转载自:http://www.study365.org/blog/45.html CentOS一般都会提供DVD1和DVD2两个镜像文件,形如CentOS-6.8-x86_64-bin-DVD1.is ...
- Android小知识汇总
1.Android Studio 将module编译打包成aar文件,module依赖的 (例如 compile 'com.zhy:autolayout:1.4.3' )不会被打包进入aar文件,应用 ...