我正在尝试获取自动显示标注的注释。我已经设法这样做了,但是当这样做时,地图出于某种原因放大了北冰洋中部。有人知道为什么会这样吗?这是我当前的代码:
- (void)viewDidLoad
{
CLLocationCoordinate2D zoomLocation;
zoomLocation.latitude = 59.*****;
zoomLocation.longitude = 17.*****;
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 0.5 * METERS_PER_MILE, 0.5 * METERS_PER_MILE);
MKCoordinateRegion adjustedRegion = [self.mapView regionThatFits:viewRegion];
[self.mapView setRegion:adjustedRegion animated:YES];
self.mapView.delegate = self;
CLLocationCoordinate2D location = CLLocationCoordinate2DMake(59.*****, 17.*****);
MapAnnotation *annotaion = [[MapAnnotation alloc] initWithCoordinates:location title:@"*****" subTitle:@"*****"];
[self.mapView addAnnotation:annotation];
[super viewDidLoad];
}
- (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views
{
MKAnnotationView *annotationView = [views objectAtIndex:0];
id <MKAnnotation> mp = [annotationView annotation];
[mv selectAnnotation:mp animated:YES];
}