如果有多个重叠的引脚并且它们不只是想显示一些详细信息页面,我想放大。
我想出了一个解决方案,但它大部分时间都有效,但并非总是如此
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view{
MKMapPoint annotationPoint = MKMapPointForCoordinate(view.annotation.coordinate);
MKMapRect mRect = self.mapView.visibleMapRect;
MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, (mRect.size.width/view.frame.size.width)*[self.mapView currentZoomLevel]*10 , (mRect.size.height/view.frame.size.height)*[self.mapView currentZoomLevel]*10 );
NSLog(@"point rect origin %f ..%f.....size %f....%f",pointRect.origin.x, pointRect.origin.y, pointRect.size.width, pointRect.size.height);
NSSet * AnnSet = [self.mapView annotationsInMapRect:pointRect];
NSLog(@"annotations obtained :%i",[[AnnSet allObjects] count]);
// [self.mapView setVisibleMapRect:pointRect animated:YES];
NSLog(@"max zoom level :%i",[self.mapView currentZoomLevel]);
if ([[AnnSet allObjects] count]>1 && [self.mapView currentZoomLevel]<19 ) {//zoom it
[self.mapView setCenterCoordinate:view.annotation.coordinate zoomLevel:[self.mapView currentZoomLevel]+1 animated:YES];
[self.mapView deselectAnnotation:view.annotation animated:NO];
}
else{
//Show detail page
}
}
问题似乎是我如何生成pointRect。
MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, (mRect.size.width/view.frame.size.width)*[self.mapView currentZoomLevel]*10 , (mRect.size.height/view.frame.size.height)*[self.mapView currentZoomLevel]*10 );
欢迎任何形式的帮助:)