iOS 地图与定位开发系列教程(三)

MapKit框架主要提供了四个功能
1、显示地图;
2、CLLocation和地址之间的转换;
3、支持在地图上做标记(比如标记北京天安门广场);
4、 把一个位置解析成地址(比如我在水立方,想要知道确切的地址信息)。

MKMapView类主要是完成下述功能
1、显示地图,比如:显示北京市的地图;
2、提供多种显示方式,比如标准地图格式,卫星地图等;
3、支持地图的放大缩小;
4、支持在地图上做标记,比如标记天安门广场;
5、在地图上显示手机所在的当前位置。

MKMapView类的属性有:

@property MKCoordinateRegin region; //地图所显示的区域
@property CLLocationCoordinate2D centerCoordinate; //经度和纬度确定的中心位置
@property MKMapView mapType; //地图的显示类型,如:卫星地图
@property NSArray *annotations; //地图上的标记
@property MKUserLocation userLocation; //用户位置
@property id <MKMapViewDelegate>delegate; //委托类

装载地图时的回调方法有:

-(void)mapViewWillStartLocationMap:(MKMapView *) mapView; //开始装载地图
-(void)mapViewDidFinishLocationMap:(MKMapView  *)mapView; //结束装载地图
-(void)mapVewDidFailLoadingMap:(MKMapView *)mapView withError:(NSError *)error; //装载失败

当位置发生转变时的回调方法:

-(void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated; //将要更改
-(void)mapView: (MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated; //已经更改

 

 

posted on 2012-10-29 16:03  Solitary  阅读(267)  评论(0编辑  收藏  举报

导航