定位- CLGeoencoder - 反编码
#import "ViewController.h"
#import "MBProgressHUD+MJ.h"
#import <CoreLocation/CoreLocation.h>
@interface ViewController ()
@property (nonatomic, strong) CLGeocoder *geocoder; // 编码对象
@property (weak, nonatomic) IBOutlet UILabel *detailLabel; // 详细地址
@property (weak, nonatomic) IBOutlet UITextField *latitudeField; // 纬度
@property (weak, nonatomic) IBOutlet UITextField *longitudeField; // 经度
@end
@implementation ViewController
/**
* 反地理编码
*
*/
- (IBAction)encoderBtn:(id)sender
{
// 1. 获取用户输入的经纬度
NSString *longitude = self.longitudeField.text;
NSString *latitude = self.latitudeField.text;
if (longitude.length == 0 || longitude == nil || latitude.length == 0 || latitude == nil) {
[MBProgressHUD showError:@"请输入经纬度" toView:self.view];
return;
}
// 2. 创建CLLocation对象
CLLocation *location = [[CLLocation alloc] initWithLatitude:[latitude doubleValue] longitude:[longitude doubleValue]];
// 3. 反编码 - 输出地标信息
/**
* 反编码
*
* @param CLLocation - 有经度纬度等信息
*/
[self.geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
for (CLPlacemark *placemark in placemarks) {
LogRed(@"%@ -- %@ --- %f --- %f",placemark.name, placemark.addressDictionary, placemark.location.coordinate.longitude, placemark.location.coordinate.latitude);
NSMutableString *mutstr = [NSMutableString string];
for (NSString *subStr in placemark.addressDictionary[@"FormattedAddressLines"]) {
[mutstr appendString:subStr];
}
LogGreen(@"%@",mutstr);
}
}];
}
- (void)viewDidLoad {
[super viewDidLoad];
//
}
/**
* 懒加载
*/
- (CLGeocoder *)geocoder{
if (!_geocoder) {
_geocoder = [[CLGeocoder alloc] init];
}
return _geocoder;
}
定位- CLGeoencoder - 反编码的更多相关文章
- 地图定位CoreLocation框架,地理位置编码与反编码
在现代互联网时代,越来越多的应用,都用到了地图定位功能,在iOS开发中,想要加入这种功能,必须基于两个框架进行开发: 1.Map Kit:用于显示地图, 2.CoreLocation:用于显示地理位置 ...
- 使用apache-commons-lang3架构对HTML内容进行编码和反编码
String a="<br>"; String a_str=StringEscapeUtils.escapeHtml4(a);//编码 System.out.print ...
- IOS CLLocationManager定位反编码位置信息
//获取位置和坐标#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_1 if (IOS_VERSION >= 8.0) { ...
- iOS 定位于地理反编码
- (void)viewDidLoad { [self startLocation]; } //开始定位 -(void)startLocation{ self.locationManager = [[ ...
- 用unescape反编码得出汉字
var p="",s="4e00"; for( var i=0;i<255;i++){ p+=unescape(("\\u"+s).r ...
- iOS 原生地图地理编码与反地理编码
当我们要在App实现功能:输入地名,编码为经纬度,实现导航功能. 那么,我需要用到原生地图中的地理编码功能,而在Core Location中主要包含了定位.地理编码(包括反编码)功能. 在文件中导入 ...
- iOS开发系列--地图与定位
概览 现在很多社交.电商.团购应用都引入了地图和定位功能,似乎地图功能不再是地图应用和导航应用所特有的.的确,有了地图和定位功能确实让我们的生活更加丰富多彩,极大的改变了我们的生活方式.例如你到了一个 ...
- Android之仿ele地图定位效果
PS:最近项目要求,希望在选择地址的时候能够仿ele来实现定位效果.因此就去做了一下.不过ele使用高德地图实现的,我是用百度地图实现的.没办法,公司说用百度那就用百度的吧.个人觉得高德应该更加的精准 ...
- iOS进阶_地图定位
一.定位步骤 1.Xcode自带地图,直接先引入头文件 #import <CoreLocation/CoreLocation.h> 2.CLLocation框架中的CLLocationMa ...
随机推荐
- cocos2dx js文件加密为jsc文件
发布产品,脚本代码是必须要加密的 偶尔会出现编译后的jsc无法运行,或者某些jsb自定义的函数找不到, 最好将require("jsb.js")的全部内容整合到一个文件,然后编译j ...
- Ubuntu上架设PPPoE Server
一.安裝 PPPoE Server Software1)sudo apt-get install ppp2)rp-pppoe(非apt套件)wget -c http://www.roaringpeng ...
- Kafka 0.8: 多日志文件夹机制
kafka 0.7.2 中对log.dir的定义如下: log.dir none Specifies the root directory in which all log data is kept. ...
- Mac上安装boost开放环境
方法一: 去Macports官网的下载页面(https://distfiles.macports.org/MacPorts/)下载对用Mac系统的pkg文件,下载完成之后,双击,一路[下一步],到安装 ...
- docker daemonize sshd service
# 第一个-d表示让容器在后台运行 # 末尾的-D表示启动ssh的daemon模式,不然容器启动后立刻就变为停止状态了 docker run -d NAME/VERSION /etc/init.d/s ...
- 全球5大安全工具Linux发行版本
全球5大安全工具Linux发行版本http://automationqa.com/forum.php?mod=viewthread&tid=2314&fromuid=21
- C#操控条形码扫描枪
// 条码扫描器 // 窗体部分相关代码: using System; using System.Collections.Generic; using System.ComponentModel; u ...
- 搭建用友开发环境(基于碧桂园的nchome)
1.解压uap_studio6.3 2.授权 3.解压ufjdk.rar到指定路径 4.配置java的环境变量 5.解压BGY50602.7z到指定目录 6.然后在studio中导入BYG5002 7 ...
- c#常用的一些命名空间
using System.Collections; 有ArrayList;Hashtable;Stack;Queue;DictionaryEntry;等集合 using System.Data; 访问 ...
- (转) ASP.NET反射
原文:http://www.cnblogs.com/zizo/p/3509895.html 两个现实中的例子:1.B超:大家体检的时候大概都做过B超吧,B超可以透过肚皮探测到你内脏的生理情况.这是如何 ...