#import <MapKit/MKMapView.h>

@interface ViewController (){
CLLocationManager *_currentLoaction;
CLGeocoder *_geocoder;
CLPlacemark *_placeMark;
} - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
_geocoder = [[CLGeocoder alloc] init]; _currentLoaction = [[CLLocationManager alloc] init];
_currentLoaction.delegate = self;
[_currentLoaction startUpdatingLocation];
} #pragma mark - Location
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
NSLog(@"locError:%@", error);
} - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
CLLocationCoordinate2D locat = [newLocation coordinate];
double lattitude = locat.latitude;
double longitude = locat.longitude;
CLGeocodeCompletionHandler handler = ^(NSArray *placemark, NSError *error)
{
for (CLPlacemark *mark in placemark) {
NSMutableDictionary *area_dic = [mark addressDictionary];
[area_dic setValue:[NSString stringWithFormat:@"%f", lattitude] forKeyPath:@"lattitude"];
[area_dic setValue:[NSString stringWithFormat:@"%f", longitude] forKeyPath:@"longitude"];
NSLog(@"area_dic is %@", area_dic); NSArray *array = [area_dic objectForKey:@"FormattedAddressLines"];
NSString *address = [area_dic objectForKey:@"FormattedAddressLines"];
NSLog(@"array is %@", array);
address = [array objectAtIndex:0];
NSLog(@"address is %@", address);
address = [area_dic objectForKey:@"City"];
NSLog(@"City is %@", address);
}
};
[_geocoder reverseGeocodeLocation:newLocation completionHandler:handler];
}

iOS下获取用户当前位置的信息的更多相关文章

  1. CDN 环境下获取用户IP方法

    CDN 环境下获取用户IP方法 1 cdn 自定义header头的X-Real-IP,在后端使用$http_x_real_ip获得 proxy_set_header X-Real-IP $remote ...

  2. 设置Cookie,登录记住用户登录信息,获取用户登录过得信息

    function setCookie(name,value) { var Days = 30; var exp = new Date(); exp.setTime(exp.getTime() + Da ...

  3. 获取用户当前位置信息的两种方法——H5、微信

    在之前的 调用百度地图API的总结 中获取当前位置信息我用的是 H5 ,其实微信也提供了获取用户地理位置的方法,现将这两种方法都贴出来,看情况选择使用. 一.H5 获取当前地理位置得到经纬度 // H ...

  4. html5获取用户当前位置

    支持地理定位的浏览器有IE9+.Firefox 3.5+ .Opera 10.6+ .Safari 5+ .Chrome.iOS 版Safari.Android版WebKit. navigator.g ...

  5. Cordova webapp实战开发:(6)如何写一个iOS下获取APP版本号的插件?

    上一篇我们学习了如何写一个Andorid下自动更新的插件,我想还有一部分看本系列blog的开发人员希望学习在iOS下如何做插件的吧,那么今天你就可以来看看这篇文字了. 本次练习你能学到的 学习如何获取 ...

  6. QT获取窗口大小和位置等信息

    QT窗口尺寸,窗口大小和大小改变引起的事件 QResizeEvent. 来源:http://blog.csdn.net/dbzhang800/article/details/6741344?reloa ...

  7. datePicker 及 timePicker 监听事件 获取用户选择 年月日分秒信息

    public class MainActivity extends AppCompatActivity { private TimePicker timePicker; private DatePic ...

  8. H5地理定位获取用户当前位置、城市

    第一步:需要在百度地图开发者平台创建一个应用:http://lbsyun.baidu.com/apiconsole/key/create 配置信息 申请配置成功以后返回一个AK 第二步:引入百度地图的 ...

  9. 获取用户的相关请求信息, 以及包括请求头 request.environ

    #在index文件中 1. print(type(request)) #看出所属库 2. from django.core.handlers.wsgi import WSGIRequest #查看WS ...

随机推荐

  1. codeforces 651A Joysticks

    A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  2. TQMsgPack序列还原clientdataset.data

    序列 procedure TForm1.Button2Click(Sender: TObject);var msgpack: TQMsgPack;begin msgpack := TQMsgPack. ...

  3. 判断滑动方向UITableView

    CGFloat lastContentOffset;  //ScoreView 滑动位置 -(void)scrollViewWillBeginDragging:(UIScrollView*)scrol ...

  4. CommandLine 和 Options

    用到的jar包 <dependency> <groupId>commons-cli</groupId> <artifactId>commons-cli& ...

  5. 12个有趣的C语言面试题

    摘要:12个C语言面试题,涉及指针.进程.运算.结构体.函数.内存,看看你能做出几个! 1.gets()函数 问:请找出下面代码里的问题: #include<stdio.h> int ma ...

  6. Spring3.0 入门进阶(三):基于XML方式的AOP使用

    AOP是一个比较通用的概念,主要关注的内容用一句话来说就是"如何使用一个对象代理另外一个对象",不同的框架会有不同的实现,Aspectj 是在编译期就绑定了代理对象与被代理对象的关 ...

  7. python字符串相关的函数

    有些是字符串对象的方法,有些是内建库的方法 split分割字符串 find 查找字符串 for c in str:  遍历字符串 len 获取字符串长度 int    将字符串转换成int str   ...

  8. too many automatic redirections were attempted

    用HttpClient时发现一下页面跳转现象. 页面A要求授权自动跳转到页面B, 页面B进行了授权,在HTTP Header里要求SetCookie并跳转到页面A. 再次请求页面A的时候没有带上此Co ...

  9. 密码强度应用(js)

    <!-- 密码强度div --> <div id="tips" class="help-block"> <b class=&quo ...

  10. Android 实现书籍翻页效果----升级篇

    自从之前发布了<Android 实现书籍翻页效果----完结篇 >之后,收到了很多朋友给我留言,前段时间由于事情较多,博客写得太匆忙很多细节地方没有描述清楚.所以不少人对其中的地方有不少不 ...