OCMapView
OCMapView copied to clipboard
FilterAnnotationsForVisibleMap has problems with some of my annotations
I had some problems with a part of my annotations that are disappearing when i zoom in. The viewForAnnotation delegate was no longer called for this annotations and when i zoom out they appear again. In my application that contents annotations in portugal, Spain, Italy, Swizerland, Germany and Greek this only happens for the annotations in portugal. It seems that filterAnnotationsForVisibleMap is not working properly for that annotations.
I just replaced the code of that method with the following and now it if working fine for me:
-
(NSArray *)filterAnnotationsForVisibleMap:(NSArray *)annotationsToFilter { NSMutableArray *filteredAnnotations = [[NSMutableArray alloc] initWithCapacity:[annotationsToFilter count]];
MKCoordinateRegion self_region = self.region;
for (id<MKAnnotation> annotation in annotationsToFilter) { // if annotation is not inside the coordinates, kick it if([annotation coordinate].latitude > (self_region.center.latitude - self_region.span.latitudeDelta/2.0) && [annotation coordinate].latitude < (self_region.center.latitude + self_region.span.latitudeDelta/2.0) && [annotation coordinate].longitude > (self_region.center.longitude - self_region.span.longitudeDelta/2.0) && [annotation coordinate].longitude < (self_region.center.longitude + self_region.span.longitudeDelta/2.0)) { [filteredAnnotations addObject:annotation]; } }
return filteredAnnotations; }
Same problem , thank you for this solution that works perfectly Thank you