IOS CLLocationManager定位反编码位置信息
//获取位置和坐标
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_1
if (IOS_VERSION >= 8.0) {
//由于IOS8中定位的授权机制改变 需要进行手动授权
//获取授权认证
[locationManager requestAlwaysAuthorization];
[locationManager requestWhenInUseAuthorization];
}
#else
#endif
if ([CLLocationManager locationServicesEnabled] == YES) {
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManager startUpdatingLocation];
} else {
[self clearLocation];
}
#pragma mark CLLocationManagerDelegate Method
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{
debugLog(@"获取到定位信息");
CLLocation *cllocation = [locations objectAtIndex:0];
NSString *longtitudeStr = [NSString stringWithFormat:@"%f", cllocation.coordinate.longitude];
NSString *latitudeStr = [NSString stringWithFormat:@"%f", cllocation.coordinate.latitude];
[manager stopUpdatingLocation];
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:cllocation completionHandler:^(NSArray *placemarks, NSError *error) {
if (error == nil) {
if ([Common isEmptyArray:placemarks] == NO) {
CLPlacemark *placemark = [placemarks objectAtIndex:0];
NSString *administrativeArea = placemark.administrativeArea;
NSString *city = placemark.locality;
NSString *subLocality = placemark.subLocality;
NSString *thoroughfare = placemark.thoroughfare;
if ([Common isEmptyString:administrativeArea] == YES) {
administrativeArea = @"";
}
if ([Common isEmptyString:city] == YES) {
city = @"";
}
if ([Common isEmptyString:subLocality] == YES) {
subLocality = @"";
}
if ([Common isEmptyString:thoroughfare] == YES) {
thoroughfare = @"";
}
NSString *locationStr = [administrativeArea stringByAppendingString:city];
locationStr = [locationStr stringByAppendingString:subLocality];
locationStr = [locationStr stringByAppendingString:thoroughfare];
[self updateLongtitude:longtitudeStr];
[self updateLatitude:latitudeStr];
[self updateLocation:locationStr];
} else {
[self clearLocation];
}
} else {
debugLog(@"获取定位信息失败, 失败原因 = %@", error.localizedDescription);
[self clearLocation];
}
[manager setDelegate:nil];
}];
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
debugLog(@"获取定位信息失败, 失败原因 = %@", error.localizedDescription);
[self clearLocation];
}
IOS CLLocationManager定位反编码位置信息的更多相关文章
- android GPS 定位,取位置信息
现在很多app ,需要取位置信息,所以我也做了一个模块用来取位置信息: 加入位置服务所需的权限: <uses-permission android:name="android.pe ...
- 定位 - CoreLocation - 打印位置信息
1. 导入框架 <CoreLocation.framework>, 引入头文件 import <CoreLocation/CoreLocation.h>; 2. 创建管理者对象 ...
- iOS CLLocationManager定位
本文转载至 http://www.tuicool.com/articles/7JBRZn 在iOS8以前的版本中,我们使用CLLocationManager定位是没有问题的,最近在iOS8系统中却无法 ...
- iOS 定位于地理反编码
- (void)viewDidLoad { [self startLocation]; } //开始定位 -(void)startLocation{ self.locationManager = [[ ...
- Android 集成GoogleMap,实现定位和获取位置信息
1.准备 我使用的是AS2.2.2,首先FQ注册google开发者帐号,准备获取API Key,网上有许多相关资料我就不再赘述,这里讲一个比较小白级的获取方法,可以减少许多输入 1.1. AS创建项目 ...
- ios 定位获取当前位置信息
啊,倦怠的人生啊~~ 什么事情都没做一眨眼就2点半了啊!!赶紧爬起来写博客啊. 诸位看官会鄙视我么,表示我真心不是把这当技术文章写的啊. 啊,下午我们来第二篇.获取地理位置信息.嗯嗯,秘籍上说叫逆向地 ...
- iOS CLLocationManager 定位
今天写个定位,本来很简单,但是在填写plist时,通过系统提示,只能看到NSLocationUsageDescription项目,根本不提示 (1)NSLocationAlwaysUsageDescr ...
- iOS开发----地图与导航--定位和位置信息获取
要实现地图.导航功能,往往需要先熟悉定位功能,在iOS中通过Core Location框架进行定位操作.Core Location自身可以单独使用,和地图开发框架MapKit完全是独立的,但是往往地图 ...
- iOS定位和位置信息获取
要实现地图.导航功能,往往需要先熟悉定位功能,在iOS中通过Core Location框架进行定位操作.Core Location自身可以单独使用,和地图开发框架MapKit完全是独立的,但是往往地图 ...
随机推荐
- java中使用正则表达式
1.用正则表达式分割字符串 Pattern SPLIT2 = Pattern.compile("[,]"); String[] tmpStrings1 = SPLIT2.split ...
- Python标准库的学习准备
作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! Python标准库是Python强大的动力所在,我们已经在前文中有所介绍.由于标准 ...
- 第一个APP:IOS做简单运算的计算器
步骤: 1.打开Xcode,单机Creat a new Xcode project 2.左边选择ios下Application,右边选择single view Application 3.填写项目名称 ...
- ajax 如何实现页面跳转
老师,您好.jquery的ajax如何实现页面跳转?例如:登陆页面属于用户名和密码后,点击登陆,验证用户名和密码,正确后,跳转到其他页面.能否给个例子. 下面列了五个例子来详细说明,这几个例子的主要功 ...
- (easy)LeetCode 205.Reverse Linked List
Reverse a singly linked list. 解法一:记录单链表每个节点的val,然后重新为单链表赋值.(取巧,仅仅是将val部分改变,原始node节点并没有改变) 代码如下: /** ...
- AM3359之U-boot及kernel编译
我用的PC主机是ubuntu12.04 LST 32位系统给出官方软件下载地址:TI官网SDK包06.00版本下载:http://software-dl.ti.com/sitara_linux/esd ...
- visual studio 中快捷键的使用
我在使用编辑器的过程中是比较喜欢使用快捷键的,因为这样可以在操作中更加便捷 ①ctrl+k,ctrl+d,代码重排 ②ctrl+k,k就是ctrl键加连续两次k键,添加书签,然后通过ctrl+k,ct ...
- OC基础(17)
ARC基本概念 ARC快速入门 ARC下的内存管理 ARC和MRC兼容和转换 *:first-child { margin-top: 0 !important; } body > *:last- ...
- HDU 1856
http://acm.split.hdu.edu.cn/showproblem.php?pid=1856 对于这道题,主要就是让你求出有最多结点的树的树叶: 我们只要利用并查集的知识吧所输入的数据连接 ...
- WebsitePanel 2.1.0beta配置部分
到http://www.websitepanel.net/downloads/下载好单独安装包作为网站内容运行在IIS7.0上,配置applicationpool为localsystem Websit ...