地图应用经常会涉及到线路的绘制问题,ios下可以使用MKMapView进行地图开发,使用
修改实现代码,在.m中添加如下代码:
MKOverlayView进行线路的绘制。
使用MKMapView添加MKMap.framework 和CoreLocation.framework并导入
MapKit.h头文件。
新建一个基于视图的工程,修改头文件:
//
// CloViewController.h
// LocationMapTest
//
// Created by Cloay on 12-6-18.
// Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import "CloMKAnnotation.h"
@interface CloViewController : UIViewController<CLLocationManagerDelegate, MKMapViewDelegate, UIActionSheetDelegate>{
MKMapView *cloMapView;
MKPolyline *routeLine;
}
@property (nonatomic, strong) NSMutableArray *locations;
@end
修改实现代码,在.m中添加如下代码:
//
// CloViewController.m
// LocationMapTest
//
// Created by Cloay on 12-6-18.
// Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//
#import "CloViewController.h"
@interface CloViewController ()
@end
@implementation CloViewController
@synthesize locations;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
cloMapView = [[MKMapView alloc] initWithFrame:[self.view bounds]];
[cloMapView setMapType:MKMapTypeHybrid]; //设置地图类型 地图/卫星/两者结合
[cloMapView setShowsUserLocation:YES]; //显示当前位置
[cloMapView setDelegate:s