美文网首页
地理位置

地理位置

作者: lifeLL | 来源:发表于2019-01-17 16:50 被阅读0次
  • (void)navigationByMapLocationName:(NSString *)locationName lat:(NSString *)lat lon:(NSString *)lon {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];

UIAlertAction * alertAction = [UIAlertAction actionWithTitle:@"使用苹果自带地图" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

    MKMapItem *currentLocation = [MKMapItem mapItemForCurrentLocation];

// MKMapItem *location = [[MKMapItem alloc] ]

    MKMapItem *toLocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark alloc] initWithCoordinate:CLLocationCoordinate2DMake([lat doubleValue], [lon doubleValue]) addressDictionary:nil]]; //目的地坐标
    toLocation.name = locationName; //目的地名字
    [MKMapItem openMapsWithItems:@[currentLocation,toLocation] launchOptions:@{MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeWalking,MKLaunchOptionsShowsTrafficKey: [NSNumber numberWithBool:NO]}];

}];
[alertController addAction:alertAction];

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"baidumap://"]]) {
    UIAlertAction * alertAction = [UIAlertAction actionWithTitle:@"使用百度地图" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        if (locationName) {
            NSString *urlString;
            urlString = [NSString stringWithFormat:@"baidumap://map/geocoder?address=%@&src=八度空间",locationName];
            urlString = [urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
            NSURL *url = [NSURL URLWithString:urlString];
            [[UIApplication sharedApplication] openURL:url];
        }
    }];
    [alertController addAction:alertAction];
}

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"iosamap://"]]) {
    
    
    UIAlertAction * alertAction = [UIAlertAction actionWithTitle:@"使用高德地图" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        if (locationName) {
            NSString *urlString;
            
            urlString = [NSString stringWithFormat:@"iosamap://poi?sourceApplication=八度空间&name=%@",locationName];
            urlString = [urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
            
            NSURL *url = [NSURL URLWithString:urlString];
            [[UIApplication sharedApplication] openURL:url];
        }
    }];
    [alertController addAction:alertAction];
    
}
UIAlertAction *alertAction4 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
    
}];
[alertController addAction:alertAction4];

[[ShareOpenUrl cyl_tabBarController] presentViewController:alertController animated:YES completion:nil];

}

相关文章

  • Redis学习笔记(二)——三大特殊数据类型

    2.1 geospatial 地理位置 geospatial 地理位置 这个功能可以推算地理位置的信息,两地之间的...

  • Leancloud 地理位置

    LeanCloud地理位置查询: 在创建的时候需要将地理位置传进去 根据AVFeoPoint创建地理位置: 、、A...

  • redis笔记-day02

    geospatial地理位置 Redis的Geo可以推算出地理位置信息,两地之间的距离 geoadd 添加地理位置...

  • 地理位置

    将我的位置准确的展示在地图上 此处用了高德地图的API 参考: https://www.cnblogs.com/z...

  • 地理位置

    地理位置 整理https://blog.csdn.net/syh523364/article/details/58...

  • 地理位置

    我们还可以通过浏览器navigator获得我们当前所在的位置geolocation。 位置的信息包括经度longi...

  • 地理位置

  • 地理位置

    (void)navigationByMapLocationName:(NSString *)locationNam...

  • HTML5 地理位置

    一、简介 地理位置特性能够识别你所在的地理位置并且在你允许的情况下,把位置信息分享给别人。 识别地理位置的方法: ...

  • 我想认识你——说说地理位置社交网络

    说到2014什么模式最火?O2O。说到O2O什么要素必须?地理位置。说到地理位置是谁的地理位置?用户哒。说到用户怎...

网友评论

      本文标题:地理位置

      本文链接:https://www.haomeiwen.com/subject/tvgidqtx.html