美文网首页
(IOS)根据经纬度获取城市等信息

(IOS)根据经纬度获取城市等信息

作者: rightmost | 来源:发表于2018-08-10 17:30 被阅读0次

// 创建经纬度

    CLLocation*location = [[CLLocationalloc] initWithLatitude:latitude longitude:longitude];

    //创建一个译码器

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

    [cLGeocoder reverseGeocodeLocation:userLocation completionHandler:^(NSArray *placemarks, NSError *error) {

        CLPlacemark *place = [placemarks objectAtIndex:0];

        // 位置名

          NSLog(@"name,%@",place.name);

          // 街道

          NSLog(@"thoroughfare,%@",place.thoroughfare);

          // 子街道

          NSLog(@"subThoroughfare,%@",place.subThoroughfare);

          // 市

          NSLog(@"locality,%@",place.locality);

          // 区

          NSLog(@"subLocality,%@",place.subLocality);

          // 国家

          NSLog(@"country,%@",place.country);

    }

     }];

    /*  CLPlacemark中属性含义

     name                    地名

     thoroughfare            街道

     subThoroughfare        街道相关信息,例如门牌等

     locality                城市

     subLocality            城市相关信息,例如标志性建筑

     administrativeArea      直辖市

     subAdministrativeArea  其他行政区域信息(自治区等)

     postalCode              邮编

     ISOcountryCode          国家编码

     country                国家

     inlandWater            水源,湖泊

     ocean                  海洋

     areasOfInterest        关联的或利益相关的地标

     */

相关文章

网友评论

      本文标题:(IOS)根据经纬度获取城市等信息

      本文链接:https://www.haomeiwen.com/subject/uvjlbftx.html