zoukankan      html  css  js  c++  java
  • iOS 地图与定位开发系列教程(四)

    MKPlacemark、MKUserLocation和MKReverseGeocoder

    在地图上做标记是通过MKPlacemark类来完成的。这个类使用(符合)MKAnnotation协议。MKAnnotation包含了多个属性,如:位置(经纬度,CLLocationCoordinate2D类型)、文字标记信息(NSString类型)等。
    MKPlacemark保存了位置(经纬度)和地址(字典类)之间的映射。下面是它的初始化方法:

    -(void)initWithCoordinate:(CLLocationCoordinate2D *)coordinate addressDictionary:(NSDictionary *)dictionary;

    MKUserLocation就是指手机的当前位置,它是MKAnnotation的一个特别案例(因为MKAnnotation可以是地图上的任何标记,而MKUserLocation只是标记了地图上手机所在的当前位置)。这个类包含了多个属性:手机的位置(类型为CLLocation)、位置文字信息(类型为NSString)等。
    MKPlacemark保存了位置(经纬度)和地址之间的映射。那么,有没有工具在这两者之间做转换呢?这就是MKRecerseGeocoder.给定一个位置信息,这个类可以返回相应的地址信息。MKReverseGeocoder的初始化方法为:

    -(void)initWithCoodinate:(CLLocationCoordinate2D)coordinate;

    下面是MKReverseGeocoder常用的一些属性和方法:

    @property id <MKReverseGeocoderDelegate>delegate; //委托
    -(void)start; //开始转换
    -(void)cancel; //取消转换

    回调的方法有:

    -(void)reverseGeocoder:(MKReverseGeocoder *) geocoded didFindPlacemark:(MKPlacemark *)placemark;  //转换成功
    -(void)reverseGeocoder : (MKReverseGeocoder *)geocoded didFailWithError:(NSError *)error; //转换失败
  • 相关阅读:
    第二章Maven安装与配置
    第一章 Maven简介
    什么是Maven?
    jbpm与OA项目-oa概念
    Hadoop学习常用的Linux命令
    包名命名规则
    判断网络类型
    webview的设置
    AlertDialog的实现
    SharedPreferences保存用户偏好参数
  • 原文地址:https://www.cnblogs.com/solitary/p/2744902.html
Copyright © 2011-2022 走看看