//显示地图
MKMapView *mapView = [[MKMapView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
mapView.showsUserLocation = YES;
[self.view addSubview:mapView];
//显示当前用户经纬度,自动缩放到1000米
CLLocationManager *locationManager = [[CLLocationManager alloc] init];//创建位置管理器
locationManager.delegate=self;//设置代理
locationManager.desiredAccuracy=kCLLocationAccuracyBest;//指定需要的精度级别
locationManager.distanceFilter=10.0f;//设置距离筛选器
[locationManager startUpdatingLocation];//启动位置管理器
MKCoordinateSpan theSpan;
//地图的范围 越小越精确
theSpan.latitudeDelta=0.05;
theSpan.longitudeDelta=0.05;
MKCoordinateRegion theRegion;
theRegion.center=[[locationManager location] coordinate];
theRegion.span=theSpan;
[mapView setRegion:theRegion];
[locationManager release];
[mapView release];
MKMapView 显示当前位置
最新推荐文章于 2019-05-18 15:39:03 发布