MKReverseGeocoder 过时,IOS5中使用CLGeocoder

MKReverseGeocoder 过时,IOS5中使用CLGeocoder

CLGeocoder是iOS5中新加的一个类,其实跟之前的MKReverseGeocoder很相似,不过CLGeocoder是以一种block的形式来反向地理编码的。

看了官方的文档,MKReverseGeocoder在iOS5中被禁止了,但其实你还是可以使用这个的,只不过在未来的某个时间,会从文档中删除掉,而且苹果这次增加的CLGeocoder类,跟CoreLocation整合在了一起,其实想想也应该是一起的,定位,反向,本应该属于一个系列的。

CLGeocoder类中有几个方法,一个是把经纬度转化成大家能看懂的信息,比如:city,county,街道等等,CLGeocoder类中的其他几个方法也非常的给里,可以把city,county等信息直接转化为坐标,以前大家可能都去githud上下载过把地点名字转回到坐标的demo,现在不用了,apple直接提供了接口给大家使用,我也今天才发现的...哎

// reverse geocode requests
- (void)reverseGeocodeLocation:(CLLocation *)location completionHandler:(CLGeocodeCompletionHandler)completionHandler;

// forward geocode requests
// geocodeAddressDictionary:completionHandler: takes an address dictionary as defined by the AddressBook framework.
// You can obtain an address dictionary from an ABPerson by retrieving the kABPersonAddressProperty property.
// Alternately, one can be constructed using the kABPersonAddress* keys defined in <AddressBook/ABPerson.h>.

- (void)geocodeAddressDictionary:(NSDictionary *)addressDictionary completionHandler:(CLGeocodeCompletionHandler)completionHandler;
- (void)geocodeAddressString:(NSString *)addressString completionHandler:(CLGeocodeCompletionHandler)completionHandler;
- (void)geocodeAddressString:(NSString *)addressString inRegion:(CLRegion *)region completionHandler:(CLGeocodeCompletionHandler)completionHandler;

- (void)cancelGeocode;
一共就这么几个方法,使用的时候,记着把device升级到ios5版

下面发个截图说下使用发放吧,非常简单,ios都更新到5了,咱们也应该科学的跟随一下,当然,不想用CLGeocoder而还坚持使用MKReverseGeocoder的也完全没问题


  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值