// 准确打开方式
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {
CLLocationCoordinate2D coordinate=userLocation.coordinate;//位置坐标
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(coordinate, 500, 500);//定位放大
[self.mapView setRegion:region animated:YES];
}
//有误差的打开方式
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{
CLLocation *location=[locations firstObject];//取出第一个位置
CLLocationCoordinate2D coordinate=location.coordinate;//位置坐标
NSLog(@"经度:%f,纬度:%f,海拔:%f,航向:%f,行走速度:%f",coordinate.longitude,coordinate.latitude,location.altitude,location.course,location.speed);
//如果不需要实时定位,使用完即使关闭定位服务
[_locationManager stopUpdatingLocation];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(coordinate, 500, 500);//定位放大
[self.mapView setCenterCoordinate:coordinate animated:YES];
[self.mapView setRegion:region animated:YES];
}
链接
http://stackoverflow.com/questions/8802973/ios-difference-between-the-location-i-get-from-cllocationmanager-and-mkmapview