zoukankan      html  css  js  c++  java
  • MKReverseGeocoder 过时,IOS5中使用CLGeocoder

    MKReverseGeocoder 过时,IOS5中使用CLGeocoder

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

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

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

     1 // reverse geocode requests
     2 - (void)reverseGeocodeLocation:(CLLocation *)location completionHandler:(CLGeocodeCompletionHandler)completionHandler;
     3 // forward geocode requests
     4 // geocodeAddressDictionary:completionHandler: takes an address dictionary as defined by the AddressBook framework.
     5 // You can obtain an address dictionary from an ABPerson by retrieving the kABPersonAddressProperty property.
     6 // Alternately, one can be constructed using the kABPersonAddress* keys defined in <AddressBook/ABPerson.h>.
     7 - (void)geocodeAddressDictionary:(NSDictionary *)addressDictionary completionHandler:(CLGeocodeCompletionHandler)completionHandler;
     8 - (void)geocodeAddressString:(NSString *)addressString completionHandler:(CLGeocodeCompletionHandler)completionHandler;
     9 - (void)geocodeAddressString:(NSString *)addressString inRegion:(CLRegion *)region completionHandler:(CLGeocodeCompletionHandler)completionHandler;
    10 - (void)cancelGeocode;

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

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

    模拟器中无法取得placemark,需要真机测试。

  • 相关阅读:
    【转】C++ ZLib压缩与解压缩
    【转】Log4j 配置最全说明
    【转】每个程序员都必须遵守的编程原则
    【转】MySQL忘记root密码
    【转】OpenGL开发环境配置
    Tomcat不能启动注意事项
    Tomcat不能启动注意事项
    Android通过php插入查询SQL数据库
    Ehcache学习总结(3)--Ehcache 整合Spring 使用页面、对象缓存
    Ehcache学习总结(3)--Ehcache 整合Spring 使用页面、对象缓存
  • 原文地址:https://www.cnblogs.com/ubersexual/p/3277942.html
Copyright © 2011-2022 走看看