我問我的MapView顯示用戶的當前位置,我從CLLocationManager使用startUpdatingLocation的委託獲取它的用戶的當前位置,我也向MapView添加了一些註釋,但問題是滾動地圖時顯示一些註釋地圖返回到當前用戶MapView返回到當前位置註解?
- (void)viewDidLoad
{
[super viewDidLoad];
// Get the location if the user
_locationManager = [[CLLocationManager alloc] init];
if ([CLLocationManager locationServicesEnabled])
{
_locationManager.delegate = self;
[_locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[_locationManager startUpdatingLocation];
}
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
// set the map view to the current location
MKCoordinateSpan span;
span.latitudeDelta = 0.01;
span.longitudeDelta = 0.05;
MKCoordinateRegion region;
region.span = span;
region.center = _locationManager.location.coordinate;
[self.mapView setRegion:region animated:YES];
}