Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FilterAnnotationsForVisibleMap has problems with some of my annotations #38

Open
ehuebner opened this issue Oct 8, 2014 · 1 comment

Comments

@ehuebner
Copy link

ehuebner commented Oct 8, 2014

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 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;
    }

@JHT1958
Copy link

JHT1958 commented Jan 27, 2016

Same problem , thank you for this solution that works perfectly
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants