源码地址https://download.csdn.net/download/liuyinghui523/10801074

1.在app中获得定位权限

    <key>NSLocationAlwaysUsageDescription</key><string>根据您的位置来提供服务</string><key>NSLocationUsageDescription</key><string>根据您的位置来提供服务</string><key>NSLocationWhenInUseUsageDescription</key><string>根据您的位置来提供服务</string>

2.把地图应用加入跳转URI白名单

    <key>LSApplicationQueriesSchemes</key><array><string>iosamap</string><string>baidumap</string><string>qqmap</string></array>

3.调用方法

- (IBAction)btnPress:(id)sender {CLLocationDegrees latitude = 31.178513;CLLocationDegrees longitude = 121.494612;CLLocationCoordinate2D endLocation = CLLocationCoordinate2DMake(latitude, longitude);[self navThirdMapWithLocation:endLocation andTitle:@"世博大道"];
}-(void)navThirdMapWithLocation:(CLLocationCoordinate2D)endLocation andTitle:(NSString *)titleStr{NSMutableArray *mapsA = [NSMutableArray array];//苹果原生地图方法和其他不一样NSMutableDictionary *iosMapDic = [NSMutableDictionary dictionary];iosMapDic[@"title"] = @"苹果地图";[mapsA addObject:iosMapDic];//高德地图if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"iosamap://"]]) {NSMutableDictionary *gaodeMapDic = [NSMutableDictionary dictionary];gaodeMapDic[@"title"] = @"高德地图";NSString *urlString = [[NSString stringWithFormat:@"iosamap://path?sourceApplication=ios.blackfish.XHY&dlat=%f&dlon=%f&dname=%@&style=2",endLocation.latitude,endLocation.longitude,titleStr] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];gaodeMapDic[@"url"] = urlString;[mapsA addObject:gaodeMapDic];}//百度地图if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"baidumap://"]]) {NSMutableDictionary *baiduMapDic = [NSMutableDictionary dictionary];baiduMapDic[@"title"] = @"百度地图";NSString *urlString = [[NSString stringWithFormat:@"baidumap://map/direction?origin={{我的位置}}&destination=latlng:%f,%f|name:%@&coord_type=gcj02&mode=driving&src=ios.blackfish.XHY",endLocation.latitude,endLocation.longitude,titleStr] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];baiduMapDic[@"url"] = urlString;[mapsA addObject:baiduMapDic];//腾讯地图if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"qqmap://"]]) {NSMutableDictionary *qqMapDic = [NSMutableDictionary dictionary];qqMapDic[@"title"] = @"腾讯地图";NSString *urlString = [[NSString stringWithFormat:@"qqmap://map/routeplan?from=我的位置&type=drive&to=%@&tocoord=%f,%f&coord_type=1&referer={ios.blackfish.XHY}",titleStr,endLocation.latitude,endLocation.longitude] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];qqMapDic[@"url"] = urlString;[mapsA addObject:qqMapDic];}}//手机地图个数判断if (mapsA.count > 0) {//选择UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"使用导航" message:nil preferredStyle:UIAlertControllerStyleActionSheet];NSInteger index = mapsA.count;for (int i = 0; i < index; i++) {NSString *title = mapsA[i][@"title"];NSString *urlString = mapsA[i][@"url"];if (i == 0) {UIAlertAction *iosAntion = [UIAlertAction actionWithTitle:title style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {[self appleNaiWithCoordinate:endLocation andWithMapTitle:titleStr];}];[alertVC addAction:iosAntion];continue;}UIAlertAction *action = [UIAlertAction actionWithTitle:title style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];}];[alertVC addAction:action];}UIAlertAction *cancleAct = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {}];[alertVC addAction:cancleAct];[self presentViewController:alertVC animated:YES completion:^{}];}else{NSLog(@"未检测到地图应用");}
}//唤醒苹果自带导航
- (void)appleNaiWithCoordinate:(CLLocationCoordinate2D)coordinate andWithMapTitle:(NSString *)map_title{MKMapItem *currentLocation = [MKMapItem mapItemForCurrentLocation];MKMapItem *tolocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark alloc] initWithCoordinate:coordinate addressDictionary:nil]];tolocation.name = map_title;[MKMapItem openMapsWithItems:@[currentLocation,tolocation] launchOptions:@{MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeDriving,MKLaunchOptionsShowsTrafficKey:[NSNumber numberWithBool:YES]}];
}

百度地图官方文档http://lbsyun.baidu.com/index.php?title=uri/api/ios

高德官方文档https://lbs.amap.com/api/lightmap/guide/line

iOS在APP中调用第三方地图地图(苹果,高德,百度,腾讯)相关推荐

  1. iOS之Swift实现调用第三方地图应用导航

    iOS之Swift实现调用第三方地图应用导航 开始的一些话 关于坐标系 源码 调用方法 一点注意事项 开始的一些话 作为一个"半路出家"的iOS的程序猿,一直使用OC开发,也想过使 ...

  2. APP中的第三方“支付”功能该如何测试

    经过最近几个项目的测试,APP中带有支付功能的产品有很多,那么APP中带有第三方支付功能的产品在这一模块该如何测试才尽可能的测试完整. 正常流程: 正常使用支付宝.微信.银行卡(目前使用最多的第三方支 ...

  3. 微信公众号h5实现高德/百度/腾讯地图导航

    最近做了个微信公众号h5需求是这样的 1.点击地图进入地图详情 2.地图详情包括开始导航与地图(高德,百度,腾讯)选择,点击开始导航自动跳转该地图app 首先先理一下功能: 1:第一张图是直接显示坐标 ...

  4. Android app中调用启动其他应用(系统应用和第三方应用

    一.打开第三方应用 方法一 Intent intent=new Intent(); //包名 包名+类名(全路径) intent.setClassName("com.linxcool&quo ...

  5. H5+ app vue调用第三方应用,如果没有安装跳转到应用市场详情

    1.调用第三方应用,先判断是否安装 plus.runtime.isApplicationExist({pname:pname,action:action}) pname是安卓应用程序包名,action ...

  6. 在APP里调用第三方文件管理器进行管理文件

    在一些APP开发项目中碰到如下情况: 需要管理指定目录下的文件(进行浏览.删除.排序.发送等等操作),然而自己开发这些功能显得比较费劲.这时完全可以借助开源的第三方文件浏览器实现. 在github上有 ...

  7. [Android6.0]App中调用init.rc中的服务,从而运行shell脚本

    Author: Younix Platform: RK3399 OS: Android 6.0 Kernel: 4.4 Version: v2017.07 需求:希望在 Android App 中添加 ...

  8. matlab中调用java代码_Matlab中调用第三方Java代码

    在Java中采用Matlab JA Builder可以实现调用m文件,采用这样的方式,可在Matlab的M文件中,直接调用Java类.这种方式可以表示为Java--> Matlab( m, Ja ...

  9. vue 高德地图 不同区域显示不同颜色_老司机频繁掉沟里,高德百度腾讯地图导航到底该怎么选?...

    导航类app发展至今,基本形成了三分天下的局面:高德.百度.腾讯,然而事实真的是三家平分天下么?三款不同的地图导航软件各有优缺点,至于什么路况选择哪个软件导航似乎更是一门玄学? 很多人想知道高德地图. ...

最新文章

  1. R语言lm函数拟合多项式回归模型、删除数据中的异常样本outlier、之后诊断模型( diagnostics)、使用plot函数打印回归模型的QQ图、残差拟合图、标度-位置图、残差与杠杆关系图
  2. js-ES6学习笔记-Iterator和for-of循环
  3. 基于直方图均衡化的水下激光图像处理(MATLAB仿真)
  4. python使用函数的优点-原来 Python 还有这些实用的功能和特点!
  5. 通讯录javafx和mysql_用javafx实现通讯录
  6. HDU 2836 Traversal 简单DP + 树状数组
  7. ocx控件 postmessage消息会消失_实战经验:如何检测CMFCTabCtrl控件标签页切换事件...
  8. 海润光伏上年净利扭亏“摘帽”在望
  9. iOS 开发线程 gcd
  10. vue webapp滑动事件_js_监听移动端web触屏事件_滑动响应
  11. python编写简易超市系统_简易控制台超市销售系统|Python练习系列[1]
  12. Python requests抓取有道翻译 最新版破解js加密
  13. java发卡系统_基于java的网络收费验证系统和在线付费发卡
  14. 如何优雅的学习英语?从理解英语的使用思维开始!
  15. CG CTF RE Py交易
  16. PhraseQuery slop
  17. 这些年,亲眼所见的软件公司中混迹的老油条汇总
  18. 学习笔记 | 百度搜索技巧
  19. Switch 如何使用NSCB 转换XCI NSP NSZ教程
  20. 用matlab实现运筹学最短路问题,运筹学 最短路问题.ppt

热门文章

  1. 用u盘计算机安装系统安装教程,教你如何用U盘重装系统
  2. index客户主页+页面分页的模糊查询 and add知识
  3. 超好的文件批量改名软件---★春林文件批量改名系统6.8
  4. leetcode-649:Dota2 参议院
  5. 第二章 TCP/IP 基础知识
  6. Java中键盘输入一个数组的具体操作及说明
  7. 你应该知道的人工智能机器人 ChatGPT 提示语
  8. python open文件失败_python open打开文件失败原因及解决办法
  9. 卷积神经网络的三个特点,卷积神经网络三大特点
  10. 必刷题属于哪个公司_商标交易平台哪个好,好听的商标名为企业节约30%的广告费【赞标网】...