IOS关于发起本机地图导航
来源:互联网 发布:历年进出口数据查询 编辑:程序博客网 时间:2024/06/05 19:59
#pragma mark -发起本机导航地图
-(void)locationByPhone{
__blockNSString *urlScheme =@"xxx"
__blockNSString *appName =@"应用名称"
__blockCLLocationCoordinate2D coordinate =self.coordinate;
UIAlertController *alert = [UIAlertControlleralertControllerWithTitle:@"选择地图"message:nilpreferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *action = [UIAlertActionactionWithTitle:@"苹果地图"style:UIAlertActionStyleDefaulthandler:^(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 ( [[UIApplicationsharedApplication]canOpenURL:[NSURLURLWithString:@"baidumap://"]])
{
UIAlertAction *action = [UIAlertActionactionWithTitle:@"百度地图"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction *action) {
NSString *urlString = [[NSStringstringWithFormat:@"baidumap://map/direction?origin={{我的位置}}&destination=latlng:%f,%f|name=目的地&mode=driving&coord_type=gcj02",coordinate.latitude, coordinate.longitude]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"%@",urlString);
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:urlString]];
}];
[alert addAction:action];
}
if ( [[UIApplicationsharedApplication]canOpenURL:[NSURLURLWithString:@"iosamap://"]])
{
UIAlertAction *action = [UIAlertActionactionWithTitle:@"高德地图"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction *action) {
NSString *urlString = [[NSStringstringWithFormat:@"iosamap://navi?sourceApplication=%@&backScheme=%@&lat=%f&lon=%f&dev=0&style=2",appName,urlScheme,coordinate.latitude, coordinate.longitude]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"%@",urlString);
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:urlString]];
}];
[alert addAction:action];
}
UIAlertAction *action1 = [UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleCancelhandler:nil];
[alert addAction:action1];
[self presentViewController:alert animated:YES completion:^{
}];
}
- IOS关于发起本机地图导航
- iOS 发送的位置能调用本机地图导航资料整理
- ios项目中调用百度、高德、本机地图导航(二)
- ios项目中调用百度、高德、本机地图导航
- iOS 调用地图导航
- iOS 地图导航
- iOS 调用地图导航
- iOS 调用地图导航
- iOS 调用地图导航
- ios 地图导航
- iOS地图系统导航
- iOS调用地图导航
- iOS 调用地图导航
- iOS百度地图导航
- IOS 跳转导航地图
- (ZT)iOS 调用地图导航
- iOS自带地图导航
- IOS开发之地图导航
- qt清空数据库表数据保留表结构的一种方法
- 浏览器缓存机制剖析
- 使用Google Test的一个简单例子(接合上一篇看)
- vue快速入门知识点(一)
- 【iOS】Socket/TCP 通信 发送 NSString 字符串格式数据
- IOS关于发起本机地图导航
- ffmpeg mkv转mp4
- 二分查找算法的递归与非递归实现
- 解决ueditor图片上传的弹出窗口被遮盖问题
- 算法导论(implementation of quick sort)
- 如何获取Android手机连接网络的当前局域网IP
- Boost install on Ubuntu
- vue---todolist
- Map集合的两种遍历方式