約2000の注釈があり、マップ上にすべてを表示するのが遅すぎます.. マップ上の注釈ビューを制限するにはどうすればよいですか? annotationsInMapRect
役に立つかもしれませんか?さらに情報が必要な場合はお知らせください。
MKAnnotationView
- (MKAnnotationView *)mapView:(MKMapView *)aMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if (![annotation isKindOfClass:[MyAnnotation class]])
{
return nil;
}
static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
MKAnnotationView *pinView = [aMapView dequeueReusableAnnotationViewWithIdentifier:AnnotationIdentifier];
if (pinView == nil)
{
pinView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];
pinView.canShowCallout = YES;
}
else
pinView.annotation = annotation;
MyAnnotation *myAnn = (MyAnnotation *)annotation;
pinView.image = [UIImage imageNamed:myAnn.icon];
return pinView;
}
- (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views
{
for(MKAnnotationView *annotationView in views)
{
if(annotationView.annotation == mv.userLocation)
{
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta=0.005;
span.longitudeDelta=0.005;
CLLocationCoordinate2D location=mv.userLocation.coordinate;
region.span=span;
region.center=location;
[mv setRegion:region animated:YES];
[mv regionThatFits:region];
id annotation = annotationView.annotation;
[self performSelector:@selector(selectUserLocation:) withObject:annotation afterDelay:0.5f];
}
}
}