• iOS开发之CoreLocation(二)


    CLGeocoder地理编码

    使用方法

    1     CLGeocoder *clg = [[CLGeocoder alloc] init];
    2     [clg geocodeAddressString:@"北京" completionHandler:^(NSArray *placemarks, NSError *error) {
    3         
    4     }];

    placemarks返回一个placemark

      1 Printing description of [0]->[0]:
      2 Beijing<GEOMapItemStorage: 0x7a07c1a0> {
      3     placeData =     {
      4         component =         (
      5                         {
      6                 attribution =                 {
      7                     "attribution_url" =                     (
      8                         "iosamap://viewPOIDetail?sourceApplication=apple&poiid="
      9                     );
     10                     "vendor_id" = "com.autonavi";
     11                 };
     12                 "cache_control" = CACHEABLE;
     13                 "start_index" = 0;
     14                 status = "STATUS_SUCCESS";
     15                 timestampFirstSeen = "446534233.68342";
     16                 ttl = 15811200;
     17                 type = "COMPONENT_TYPE_ENTITY";
     18                 value =                 (
     19                                         {
     20                         entity =                         {
     21                             name =                             (
     22                                                                 {
     23                                     locale = en;
     24                                     "string_value" = Beijing;
     25                                 }
     26                             );
     27                             type = "ADMINISTRATIVE_AREA";
     28                         };
     29                     }
     30                 );
     31                 "values_available" = 1;
     32                 version = 1;
     33                 "version_domain" =                 (
     34                     autonavi,
     35                     fwdgeo,
     36                     cn
     37                 );
     38             },
     39                         {
     40                 attribution =                 {
     41                     "attribution_url" =                     (
     42                         "iosamap://viewPOIDetail?sourceApplication=apple&poiid="
     43                     );
     44                     "vendor_id" = "com.autonavi";
     45                 };
     46                 "cache_control" = CACHEABLE;
     47                 "start_index" = 0;
     48                 status = "STATUS_SUCCESS";
     49                 timestampFirstSeen = "446534233.68342";
     50                 ttl = 15811200;
     51                 type = "COMPONENT_TYPE_ADDRESS";
     52                 value =                 (
     53                                         {
     54                         address =                         {
     55                             "localized_address" =                             (
     56                                                                 {
     57                                     address =                                     {
     58                                         formattedAddressLine =                                         (
     59                                             "Beijing China"
     60                                         );
     61                                         structuredAddress =                                         {
     62                                             administrativeArea = Beijing;
     63                                             country = China;
     64                                             countryCode = CN;
     65                                             geoId =                                             (
     66                                             );
     67                                             locality = Beijing;
     68                                         };
     69                                     };
     70                                     locale = en;
     71                                 }
     72                             );
     73                             "spoken_navigation_address" =                             (
     74                                                                 {
     75                                     locale = "en_US";
     76                                     "string_value" = "Beijing China";
     77                                 }
     78                             );
     79                             "spoken_structured_address" =                             (
     80                                                                 {
     81                                     "spoken_structured_address" =                                     {
     82                                         administrativeArea = Beijing;
     83                                         country = China;
     84                                         countryCode = CN;
     85                                         geoId =                                         (
     86                                         );
     87                                         locality = Beijing;
     88                                     };
     89                                 }
     90                             );
     91                         };
     92                     }
     93                 );
     94                 "values_available" = 1;
     95                 version = 1;
     96                 "version_domain" =                 (
     97                     autonavi,
     98                     fwdgeo,
     99                     cn
    100                 );
    101             },
    102                         {
    103                 attribution =                 {
    104                     "attribution_url" =                     (
    105                         "iosamap://viewPOIDetail?sourceApplication=apple&poiid="
    106                     );
    107                     "vendor_id" = "com.autonavi";
    108                 };
    109                 "cache_control" = CACHEABLE;
    110                 "start_index" = 0;
    111                 status = "STATUS_SUCCESS";
    112                 timestampFirstSeen = "446534233.68342";
    113                 ttl = 15811200;
    114                 type = "COMPONENT_TYPE_PLACE_INFO";
    115                 value =                 (
    116                                         {
    117                         "place_info" =                         {
    118                             center =                             {
    119                                 lat = "39.904989";
    120                                 lng = "116.405285";
    121                             };
    122                             timezone =                             {
    123                                 identifier = "Asia/Shanghai";
    124                             };
    125                         };
    126                     }
    127                 );
    128                 "values_available" = 1;
    129                 version = 1;
    130                 "version_domain" =                 (
    131                     autonavi,
    132                     fwdgeo,
    133                     cn
    134                 );
    135             },
    136                         {
    137                 "cache_control" = CACHEABLE;
    138                 "start_index" = 0;
    139                 status = "FAILED_NO_RESULT";
    140                 timestampFirstSeen = "446534233.68342";
    141                 type = "COMPONENT_TYPE_HOURS";
    142                 "values_available" = 0;
    143             },
    144                         {
    145                 "cache_control" = CACHEABLE;
    146                 "start_index" = 0;
    147                 status = "FAILED_NO_RESULT";
    148                 timestampFirstSeen = "446534233.68342";
    149                 type = "COMPONENT_TYPE_RATING";
    150                 "values_available" = 0;
    151             },
    152                         {
    153                 attribution =                 {
    154                     "attribution_url" =                     (
    155                         "iosamap://viewPOIDetail?sourceApplication=apple&poiid="
    156                     );
    157                     "vendor_id" = "com.autonavi";
    158                 };
    159                 "cache_control" = CACHEABLE;
    160                 "start_index" = 0;
    161                 status = "STATUS_SUCCESS";
    162                 timestampFirstSeen = "446534233.68342";
    163                 ttl = 15811200;
    164                 type = "COMPONENT_TYPE_BOUNDS";
    165                 value =                 (
    166                                         {
    167                         bounds =                         {
    168                             "map_region" =                             {
    169                                 eastLng = "115.956516";
    170                                 northLat = "39.319976";
    171                                 southLat = "40.490002";
    172                                 westLng = "116.854054";
    173                             };
    174                         };
    175                     }
    176                 );
    177                 "values_available" = 1;
    178                 version = 1;
    179                 "version_domain" =                 (
    180                     autonavi,
    181                     fwdgeo,
    182                     cn
    183                 );
    184             }
    185         );
    186         "result_provider_id" = 57879;
    187         status = "STATUS_SUCCESS";
    188     };
    189 }

    placemark的属性

     1 /*
     2  *  location
     3  *  
     4  *  Discussion:
     5  *    Returns the geographic location associated with the placemark.
     6  */
     7 @property (nonatomic, readonly, copy) CLLocation *location;
     8 
     9 /*
    10  *  region
    11  *  
    12  *  Discussion:
    13  *    Returns the geographic region associated with the placemark.
    14  */
    15 @property (nonatomic, readonly, copy) CLRegion *region;
    16 
    17 /*
    18  *  addressDictionary
    19  *  
    20  *  Discussion:
    21  *    This dictionary can be formatted as an address using ABCreateStringWithAddressDictionary,
    22  *    defined in the AddressBookUI framework.
    23  */
    24 @property (nonatomic, readonly, copy) NSDictionary *addressDictionary;
    25 
    26 // address dictionary properties
    27 @property (nonatomic, readonly, copy) NSString *name; // eg. Apple Inc.
    28 @property (nonatomic, readonly, copy) NSString *thoroughfare; // street address, eg. 1 Infinite Loop
    29 @property (nonatomic, readonly, copy) NSString *subThoroughfare; // eg. 1
    30 @property (nonatomic, readonly, copy) NSString *locality; // city, eg. Cupertino
    31 @property (nonatomic, readonly, copy) NSString *subLocality; // neighborhood, common name, eg. Mission District
    32 @property (nonatomic, readonly, copy) NSString *administrativeArea; // state, eg. CA
    33 @property (nonatomic, readonly, copy) NSString *subAdministrativeArea; // county, eg. Santa Clara
    34 @property (nonatomic, readonly, copy) NSString *postalCode; // zip code, eg. 95014
    35 @property (nonatomic, readonly, copy) NSString *ISOcountryCode; // eg. US
    36 @property (nonatomic, readonly, copy) NSString *country; // eg. United States
    37 @property (nonatomic, readonly, copy) NSString *inlandWater; // eg. Lake Tahoe
    38 @property (nonatomic, readonly, copy) NSString *ocean; // eg. Pacific Ocean
    39 @property (nonatomic, readonly, copy) NSArray *areasOfInterest; // eg. Golden Gate Park
    40 @end

    需要什么属性可以自己查找

    reverseGeocode反地理编码

     

    1     CLGeocoder *clg1 = [[CLGeocoder alloc] init];
    2     CLLocation *clt = [[CLLocation alloc] initWithLatitude:40 longitude:116];
    3     [clg1 reverseGeocodeLocation:clt completionHandler:^(NSArray *placemarks, NSError *error) {
    4         
    5     }];

    一样的东西 

  • 相关阅读:
    [转] Vue + Webpack 组件式开发(练习环境)
    [转] 从零构建 vue2 + vue-router + vuex 开发环境到入门,实现基本的登录退出功能
    [转] Redux入门教程(快速上手)
    [转] 前端数据驱动的价值
    [转] React风格的企业前端技术
    [转] 对Array.prototype.slice.call()方法的理解
    [转] webpack之plugin内部运行机制
    [转] 静态资源的分布对网站加载速度的影响/浏览器对同一域名下并发加载资源数量
    Mysql 版本号、存储引擎、索引查询
    linux 查看CPU、内存、磁盘信息命令
  • 原文地址:https://www.cnblogs.com/dongwenbo/p/4299477.html
Copyright © 2020-2023  润新知