Skip to content

FilterAnnotationsForVisibleMap has problems with some of my annotations #38

Description

@ehuebner

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions