// 準確打開方式ios
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {git
CLLocationCoordinate2D coordinate=userLocation.coordinate;//位置座標get
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(coordinate, 500, 500);//定位放大it
[self.mapView setRegion:region animated:YES];io
}date
//有偏差的打開方式map
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{im
CLLocation *location=[locations firstObject];//取出第一個位置stackoverflow
CLLocationCoordinate2D coordinate=location.coordinate;//位置座標top
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