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     }];

一样的东西

时间: 2024-10-25 12:15:52

iOS开发之CoreLocation(二)的相关文章

iOS 开发之 ZBarSDK 二维码扫描自定义二维码扫描页面(二)

iOS 开发之 ZBarSDK 二维码扫描自定义二维码扫描页面(二) 上一篇解决了ZBarSDK不支持64bit的问题,下面我们就可以使用ZBarSDK了. 导入ZBarSDk.h文件 附上代码: // //  MeViewController.m //  Auditory Blog // //  Created by 寒竹子 on 15/4/28. //  Copyright (c) 2015年 寒竹子. All rights reserved. // #define ScanWidth  2

iOS开发之CoreLocation(一)

简介 在移动互联网时代,移动app能解决用户的很多生活琐事,比如 导航:去任意陌生的地方 周边:找餐馆.找酒店.找银行.找电影院 在上述应用中,都用到了地图和定位功能,在iOS开发中,要想加入这2大功能,必须基于2个框架进行开发 Map Kit :用于地图展示 Core Location :用于地理定位 2个热门专业术语 LBS :Location Based Service SoLoMo :Social Local Mobile(索罗门) CoreLocation框架的使用 CoreLocat

ioS开发之CoreLocation(GPS定位)

1.概述 在iOS开发中,要想加入地图和定位功能这2大功能,必须基于2个框架进行开发 (1)Map Kit :用于地图展示 (2)Core Location :用于地理定位 2个热门专业术语: LBS :Location Based Service SoLoMo :Social Local Mobile(索罗门) 2.CoreLocation框架的使用 CoreLocation框架使用前提: 导入框架: 导入主头文件: #import <CoreLocation/CoreLocation.h>

iOS开发之Quartz2D 二:绘制直线,曲线,圆弧,矩形,椭圆,圆

#import "DrawView.h" @implementation DrawView /** * 作用:专门用来绘图 * 什么时候调用:当View显示的时候调用 * @param rect:当View的bounds */ - (void)drawRect:(CGRect)rect { // Drawing code // NSLog(@"%s",__func__); // NSLog(@"%@",NSStringFromCGRect(rec

iOS 开发之 ZBarSDK 二维码扫描 静态库不支持64bit完美解决(一)

由于ZBarSDK不支持arm64 bit,下面是自己进行编译打包生成支持64bit的.a文件的方法. 首先下载ZBarSDK,解压后打开iPhone的文件夹,删除Example文件夹.然后打开zbar.xcodeproject,设置工程编译环境为Release环境. 修改Standard Achived 为armv7 arm64,然后build.注意:先选择真机build,此时不需要插入真机.然后,在选择模拟器build. 得到两个.a文件. 最后一步: 将真机下得到的.a文件和模拟器下得到的

iOS定位开发之CoreLocation

有时候我们并不需要查看地图,而仅仅需要自己的当前位置就可以,这时候就没有必要去使用MapKit可,直接使用定位服务就好了 苹果提供了CoreLocation框架来做定位功能 首先要想项目中导入CoreLocation框架 定位服务开启之前最好查看一下定位服务是否可用,有可能用户已经拒绝或者用户手机定位模块有问题,无法定位 定位服务是由CLLocationManager来管理的 定位成功等信息也是通过代理发送给对象的,另外定位中经常需要用到地理位置的解码和反解码(其实就是经纬度和地名之间的转换)

iOS开发之多XIB之间相互关联

Xib link Xib 1.直接加载xib中的UIView 创建一个View1.xib, 随便设一个背景色,加一个标识UILabel, 这样好知道是这个view是哪一个view. 你可以在这个view上加作意的subview,我只是说明原理,所以这儿并没有加作何subview. 最终我的View1如下图: 由于View1会放到其它View上作为subview,所以这儿size是Freeform, Status Bar是:None. 将下面代码放到viewDidLoad中: &1这行代码就是加载

iOS开发之MVVM在项目中的应用

今天写这篇博客是想达到抛砖引玉的作用,想与大家交流一下思想,相互学习,博文中有不足之处还望大家批评指正.本篇博客的内容沿袭以往博客的风格,也是以干货为主,偶尔扯扯咸蛋(哈哈~不好好工作又开始发表博客啦~). 由于本人项目经验有限,关于架构设计方面的东西理解有限,我个人对MVVM的理解主要是借鉴于之前的用过的MVC的Web框架~在学校的时候用过ThinkPHP框架,和SSH框架,都是MVC的架构模式,今天MVVM与传统的MVC可谓是极为相似,也可以说是兄弟关系,也就是一家人了. 说到架构设计和团队

李洪强IOS开发之-iOS经典面试题

李洪强IOS开发之-iOS经典面试题 写这篇文章的目的是因为前两天同学想应聘iOS开发,从网上找了iOS面试题和答案让我帮忙看看.我扫了一眼,倒吸了一口冷气,仔细一看,气的发抖.整篇题目30多个没有一个答案是对的,总结这篇面试题的作者对iOS机制根本就是一知半解就敢发到网上,不管有心还是无心都是坑害新人.所以在这里总结一下这几年面试别人和被别人面试遇到的一些我认为比较好的基础题目分享给大家,进阶题目在后续补充.我的理解如果有错漏请一定指出,非常感谢! 从12年开始做面试官到现在已经三个年头了,这