iOS 定位于地理反编码
- (void)viewDidLoad { [self startLocation];
} //开始定位
-(void)startLocation{
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self; [self.locationManager requestWhenInUseAuthorization];
if ([[[UIDevice currentDevice]systemVersion]doubleValue]>=8.0) { [self.locationManager requestWhenInUseAuthorization];
[self.locationManager requestAlwaysAuthorization]; }
[self.locationManager startUpdatingLocation]; if ([CLLocationManager locationServicesEnabled]) {
self.locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
self.locationManager.distanceFilter = kCLDistanceFilterNone;
}else
{
NSLog(@"open fail");
} }
#pragma mark - CoreLocation 代理
#pragma mark 跟踪定位代理方法,每次位置发生变化即会执行(只要定位到相应位置)
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
CLLocation *location=[locations lastObject];
CLLocationCoordinate2D coordinate=location.coordinate;
NSLog(@"经度:%f,纬度:%f",coordinate.longitude,coordinate.latitude);
self.longitude=coordinate.longitude;
self.latitude=coordinate.latitude;
//如果不需要实时定位,使用完即使关闭定位服务
[self.locationManager stopUpdatingLocation];
[self weiZhi];
}
-(void)weiZhi
{
self.geocoder=[[CLGeocoder alloc]init];
CLLocation *rr=[[CLLocation alloc]initWithLatitude:self.latitude longitude:self.longitude];
[self.geocoder reverseGeocodeLocation:rr completionHandler:^(NSArray *placemarks, NSError *error) { CLPlacemark *mark=[placemarks objectAtIndex:];
UILabel *currentLocation=[[UILabel alloc]initWithFrame:CGRectMake(, , , )];
currentLocation.text=[NSString stringWithFormat:@"%@",mark.subLocality]; [self.locationView addSubview:currentLocation];
}]; }
-(void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
{
switch (status) {
case kCLAuthorizationStatusNotDetermined:
if ([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
{
[self.locationManager requestWhenInUseAuthorization];
}
break;
default:
break;
} }
//当定位出现错误时就会调用这个方法。
- (void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error
{
NSLog(@"error-%@",error); }
定位当前的位置。对于 CLPlacemark 还有许多属性,不仅仅可以给出当前位置,还可以给出其他信息,后续研究。。。。
iOS 定位于地理反编码的更多相关文章
- IOS CLLocationManager定位反编码位置信息
//获取位置和坐标#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_1 if (IOS_VERSION >= 8.0) { ...
- 猫猫学iOS 之CoreLocation反地理编码小Demo输入经纬度得到城市
猫猫分享,必须精品 原创文章,欢迎转载.转载请注明:翟乃玉的博客 地址:http://blog.csdn.net/u013357243 一:效果 输入经纬度,能够得到相应的地名 二:思路 跟地里编码差 ...
- iOS地理反地理编码--CoreLocation
.sidebar{float:left;width:220px;} .container-fluid>.content{margin-left:240px;} a{color:#0069d6;t ...
- AJ学IOS 之CoreLocation反地理编码小Demo输入经纬度得到城市
AJ分享,必须精品 一:效果 输入经纬度,可以得到相应的地名 二:思路 跟地里编码差不多 1.获取用户输入的经纬度 2.根据用户输入的经纬度创建CLLocation对象 3.根据CLLocation对 ...
- iOS - GeoCoder 地理编码
前言 NS_CLASS_AVAILABLE(10_8, 5_0) @interface CLGeocoder : NSObject 地理编码 地名 -> 经纬度 等具体位置数据信息.根据给定的位 ...
- 定位- CLGeoencoder - 反编码
#import "ViewController.h" #import "MBProgressHUD+MJ.h" #import <CoreLocation ...
- 地图定位CoreLocation框架,地理位置编码与反编码
在现代互联网时代,越来越多的应用,都用到了地图定位功能,在iOS开发中,想要加入这种功能,必须基于两个框架进行开发: 1.Map Kit:用于显示地图, 2.CoreLocation:用于显示地理位置 ...
- 使用多字节字符集的跨平台(PC、Android、IOS、WP)编码/解码方法
随着移动端的发展,跨平台已成为通讯架构设计的重要考虑因素,PC.Android.IOS.WP等跨多平台间的数据通讯,必然要解决字符编码/解码的问题. 多字节字符集MBCS不是跨平台的首选字符集,面向跨 ...
- 使用apache-commons-lang3架构对HTML内容进行编码和反编码
String a="<br>"; String a_str=StringEscapeUtils.escapeHtml4(a);//编码 System.out.print ...
随机推荐
- 不再折腾-----hadoop-1.2.1完全分布式安装
准备工作 三台虚拟机,强烈推荐vmware + centos6.5 三台虚拟机均设有hadoop用户 IP地址设置 IP地址 hostname 192.168.11.100 master 192.16 ...
- EaseType缓动函数
http://sol.gfxile.net/interpolation/ 一篇很详细的图文
- sqlite数据类型
sqlite数据类型(时间 日期 double等) sqlite3支持的数据类型: NULL.INTEGER.REAL.TEXT.BLOB但是,sqlite3也支持如下的数据类型smallin ...
- jquery 源码解析
静态与实力方法共享设计 遍历方法 $(".a").each() //作为实例方法存在 $.each() //作为静态方法存在 Jquery源码 jQuery.prototype = ...
- ios基础篇(二十)—— UIBezierPath绘制
UIBezierPath类可以创建基于矢量的路径,可以定义简单的形状,如椭圆或者矩形,或者有多个直线和曲线段组成的形状. 一.UIBezierPath使用: 1.创建path: 2.添加路径到path ...
- IntelliJ UI安装
- 使用urllib编写python爬虫
新版python中,urllib和urllib2合并了,统一为urllib (1)简单爬取网页 import urllib content = urllib.request.urlopen(req). ...
- position 定位
position属性是指本体相对于上级的定位,position又分绝对定位和相对定位.他的默认值是static,意味着元素没有被定位,出现在文档流中应该出现的位置.如果用position来布局页面,父 ...
- Extjs改变树节点的勾选状态
Extjs改变树节点的勾选状态 今天系统中有处地方需要一个功能点击一个按钮后将树节点前的复选框去掉,变成没有选择的状态.网上搜索了半天,然后自己查查API,终于找到解决办法了,下面把方法贴出来. 在E ...
- 【C语言学习】-06 函数
函数分类.函数声明和定义.函数调用,形参实参.函数嵌套调用