首页 > 移动平台 > 详细

iOS 地理位置反编码

时间:2015-07-27 18:04:36      阅读:538      评论:0      收藏:0      [点我收藏+]

获取城市的名字,具体还可以获得街道信息,不多说直接上代码:

 

CLLocation *currentLocation = [locations lastObject];

    MJLog(@"currentLocation == %@",currentLocation);

         // 创建位置

         CLGeocoder *revGeo = [[CLGeocoder alloc] init];

        [revGeo reverseGeocodeLocation:currentLocation completionHandler:^(NSArray *placemarks, NSError *error) {

         

        // 地理位置反编

         if (!error && [placemarks count] > 0) {

         NSDictionary *dict = [[placemarks objectAtIndex:0] addressDictionary];

         _currentPosition = [dict objectForKey:@"City"];

         MJLog(@"City address: %@",_currentPosition); }

         else  {

         Alert(@"温馨提示", @"获取位置失败");

         MJLog(@"ERROR: %@", error); }

         }];

iOS 地理位置反编码

原文:http://www.cnblogs.com/fantasy3588/p/4680439.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!