2
我想獲得一個自動顯示標註的註釋。 我已經設法做到了,但是當這樣做完成後,地圖由於某種原因放大了北冰洋的中間部分。 任何人都有一個想法,爲什麼會發生? 這裏是我當前的代碼:自動顯示MapKit註釋
- (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];
}
非常感謝您!沒想到用戶位置點也是註釋。 – user1588740 2012-08-10 01:00:56