IOS 地图导航(其中包括苹果地图、百度地图、高德地图、谷歌地图)
前言:地图导航功能如果是导入第三方包来进行开发会增加App的大小,而通过openUrl来直接打开对应App软件显然是一个性价比较高的做法,因为IPhone手机本身就带有地图功能,所有我们并不用担心会出现没有地图可以调用的情况。
话不多说,直接贴码:
#pragma mark 跳转到地图
- (void)presentedToMapView
{//用于返回到App,需要在Info中的URL Types添加NSString *urlScheme = @"";NSString *appName = @"";CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(_merchantInfo.latitude,_merchantInfo.longitude);UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"选择地图" message:@"建议在wifi下打开" preferredStyle:UIAlertControllerStyleActionSheet];//苹果地图,这个判断其实是不需要的if ( [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"http://maps.apple.com/"]]){UIAlertAction *action = [UIAlertAction actionWithTitle:@"苹果地图" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {MKMapItem *currentLocation = [MKMapItem mapItemForCurrentLocation];MKMapItem *toLocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark alloc] initWithCoordinate:coordinate addressDictionary:nil]];[MKMapItem openMapsWithItems:@[currentLocation, toLocation]launchOptions:@{MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving,MKLaunchOptionsShowsTrafficKey: [NSNumber numberWithBool:YES]}];}];[alert addAction:action];}//百度地图if ( [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"baidumap://"]]){UIAlertAction *action = [UIAlertAction actionWithTitle:@"百度地图" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {NSString *urlString = [[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:urlString]];}];[alert addAction:action];}//高德地图if ( [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"iosamap://"]]){UIAlertAction *action = [UIAlertAction actionWithTitle:@"高德地图" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {NSString *urlString = [[NSString stringWithFormat:@"iosamap://navi?sourceApplication=%@&backScheme=%@&lat=%f&lon=%f&dev=0&style=2",appName,urlScheme,coordinate.latitude, coordinate.longitude] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];}];[alert addAction:action];}//谷歌地图if ( [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"comgooglemaps://"]]){UIAlertAction *action = [UIAlertAction actionWithTitle:@"谷歌地图" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {NSString *urlString = [[NSString stringWithFormat:@"comgooglemaps://?x-source=%@&x-success=%@&saddr=&daddr=%f,%f&directionsmode=driving",appName,urlScheme,coordinate.latitude, coordinate.longitude] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];}];[alert addAction:action];}UIAlertAction *action = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];[alert addAction:action];[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alert animated:YES completion:nil];
}
IOS 地图导航(其中包括苹果地图、百度地图、高德地图、谷歌地图)相关推荐
- 在线下载离线地图瓦片 (支持百度、高德和谷歌地图)
制作离线地图,下载百度矢量数据制作3D地图,下载离线地图数据,下载离线地图瓦片.支持三个主流地图数据(百度.高德和谷歌). 下载网址:http://wmksj.com/ 1. 点击"地图下载 ...
- android 跳转腾讯地图导航,Android 跳转到百度、高德、腾讯地图导航
项目中遇到的一个需求,跳转外部App进行步行导航.分别是百度.高德.腾讯. 东西不难但是每次都要去官方文档找(有时候会更新一些字段). 所以在此做下记录和分享. 腾讯地图 try { LatLng l ...
- osgEarth的Rex引擎原理分析(七十九)如何加载百度、高德、谷歌、微软的在线地图
目标:(七十八)中的问题155 瓦片生成后,就是一堆图片.怎么对这堆图片进行编号,是目前主流互联网地图商分歧最大的地方.总结起来分为四个流派: 谷歌XYZ:Z表示缩放层级,Z=zoom:XY的原点在左 ...
- BIGEMAP(百度、高德、谷歌)离线地图二次开发
(百度.高德.谷歌)离线地图二次开发 发布时间:2019-04-10 版权: 1.如何搭建离线地图开发环境 2.下载离线地图数据(金字塔瓦片数据 ...
- (百度、高德、谷歌)离线地图二次开发
(百度.高德.谷歌)离线地图二次开发 发布时间:2019-04-10 版权: 相关链接:三维(3D)离线地图 二次开发 1.如何搭建离线地图 ...
- android auto谷歌地图,如何在 Android Auto 中使用 Waze 而不是谷歌地图
玩懂手机网教程,随着有车一族的用户越来越庞大,Android 独家应用程序比 iOS 少的多,大部分用户依旧使用智能手机进行导航,对比起来 Android Auto 正在面临一个逐步两难的境界. An ...
- vue高德、谷歌地图动态加载
vue高德.谷歌地图动态加载 前言 引入地图资源 页面使用 完整map.js 前言 因为我们这个项目,做的是国际化项目,考虑的是,在国内使用高德地图,在国外使用谷歌地图,所以在这里做了个动态引入地图, ...
- android开发游记:APP内部调启百度、高德、web地图导航
版权声明:本文为博主原创文章,未经博主允许不得转载. 目录(?)[+] 使用方法 下面解释主要代码 一些地图相关的app一般都需要集成导航的功能方便用户使用,但实际上我们很多时候仅仅只是希望提供这样一 ...
- android 腾讯地图导航,Android 根据地址调手机的高德,百度,腾讯地图导航
首先切记利用到地图,万物归结于经纬度 效果图: 效果图.png 1.基于高德的经纬度(也是基于高德坐标系) 配置:导入AMap_Location_Vxxx.jar和AMap_Search_Vxxx.j ...
- 腾讯、百度、高德、谷歌、天地图地图瓦片
以下是各地图的瓦片地图地址,可以在QGIS中加载,也可以在openlayer或leaflet前端页面中加载. 腾讯.百度.高德,加上谷歌和天地图应该足够用了.腾讯.高德是GCJ02坐标系,百度是BD0 ...
最新文章
- 从零开始制作自己的podspec
- 2017年深度学习优化算法最新进展:如何改进SGD和Adam方法?
- Vuex 入门前的小菜 - “Vue 中的简单状态共享机制实现”
- 可做fft分析吗_小吃店生意好做吗,小吃业行情分析
- winform 统计大量数据重复的元素个数_DAY10——推断统计之概率与概率分布:常见的离散型概率分布...
- 消息称字节跳动将推迟IPO 官方回应:尚无上市计划
- linux脚本中空格怎么显示,linux vim 显示空格
- 小米澄清「手机不再支持GMS」;虾米音乐正式关停;《质量效应1》DLC 因源代码损坏而移除 | 极客头条...
- jbod ugood 磁盘驱动状态_NTFS磁盘读写工具Mounty免费版
- ==和Equal()
- Linux系统下安装flash player插件
- 树状知识汇总流程图模板分享
- Spring Boot 2.1.6.RELEASE embed tomcat启动过程
- 聊天记录怎么录视频 微信聊天记录屏幕录制
- Pega How To系列之一:如何在页面上动态显示/隐藏内容 ----CheneyWang
- 恢复Cisco 2960交换机密码
- C语言经典例题:有一对兔子,从出生后第 3 个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,两年内每个月的兔子总数为多少?
- 《Large scale GAN training for high fidelity natural image synthesis》论文阅读记录
- 阿里巴巴校招笔试题型攻略
- Junit报错:Argument(s) are different! Wanted: