0

在多个位置的地图视图上显示感兴趣的位置。

MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];
    annotation.coordinate = CLLocationCoordinate2DMake([[[[InterestedLocationsAry objectAtIndex:i] objectForKey:@"Location"] objectForKey:@"latitude"] floatValue], [[[[InterestedLocationsAry objectAtIndex:i] objectForKey:@"Location"] objectForKey:@"longitude"] floatValue]);
    annotation.title = [[[InterestedLocationsAry objectAtIndex:i] objectForKey:@"Location"] objectForKey:@"name"];
    [mapView selectAnnotation:annotation animated:YES];
    [mapView addAnnotation:annotation];

它在地图视图上显示精确。在选择精确点上,它不显示 MKPointAnnotation 的弹出框。

4

1 回答 1

0

您的代码很完美,只需交换这一行

[mapView selectAnnotation:annotation animated:YES];
[mapView addAnnotation:annotation];

到这里,然后再次运行,

[mapView addAnnotation:annotation];
[self performSelector:@selector(selectAnnoation:) withObject:annotation afterDelay:0.1];


- (void)selectAnnoation:(Annotation *)annotation {
    if(annotation)
    [mapView selectAnnotation:annotation animated:YES];
}
于 2014-10-16T10:04:55.913 回答