标签:
首先在工程里导入MapKit.framework
1 #import "RootViewController.h" 2 #import <MapKit/MapKit.h> 3 @interface RootViewController ()<MKMapViewDelegate> 4 5 @end 6 7 @implementation RootViewController 8 9 - (void)viewDidLoad { 10 [super viewDidLoad]; 11 // 初始化MKMapView 12 MKMapView *mapView = [[MKMapView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 13 // 设置代理 14 mapView.delegate = self; 15 // 设置显示当前位置 16 mapView.showsUserLocation = YES; 17 // 设置地图显示类型 18 mapView.mapType = MKMapTypeStandard; 19 // 经纬度 20 CLLocationCoordinate2D coord2D = {23.117000,113.27500}; 21 // 显示范围精度 22 MKCoordinateSpan span = {0.01,0.01}; 23 // 显示区域 24 MKCoordinateRegion region = {coord2D,span}; 25 // 给地图设置显示区域 26 [mapView setRegion:region animated:YES]; 27 [self.view addSubview:mapView]; 28 } 29 30 31 @end
标签:
原文地址:http://www.cnblogs.com/lantu1989/p/4737723.html