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

annotationsToIgnore are only refreshed every other reload #4

Closed
marotan3 opened this issue Mar 4, 2012 · 1 comment
Closed

annotationsToIgnore are only refreshed every other reload #4

marotan3 opened this issue Mar 4, 2012 · 1 comment
Assignees

Comments

@marotan3
Copy link
Contributor

marotan3 commented Mar 4, 2012

hi,

I am using OCMapViews with a a few annotations that should always be visible. Adding and clustering all work, but when I zoom in or pan the view, the view is reloaded, and then the annotationsToIgnore are gone. Upon a next refresh, they are back. I could locate the issue to the final lines of the doClustering method:

    // Clear map but leave Userlcoation
    NSMutableArray *annotationsToRemove = [[NSMutableArray alloc] initWithArray:self.displayedAnnotations];
    [annotationsToRemove removeObject:self.userLocation];

    // add clustered and ignored annotations to map
    [super addAnnotations: clusteredAnnotations];
    [super addAnnotations: [annotationsToIgnore allObjects]];

    // fix for flickering
    [annotationsToRemove removeObjectsInArray: clusteredAnnotations];
    [super removeAnnotations:annotationsToRemove];

What happens is that upon first view, the annotationsToIgnore are are added to the annotations that are going to be displayed by super. However, upon second view, the annotationsToRemove is loaded with the current visible annotations., including the ones that are to be ignored during clustering. Of course, they are added when [super addAnnotations: [annotationsToIgnore allObjects]]; is executed, but as annotationsToIgnore objects are also in the annotationsToRemove, they are basically added at first but removed at the next line. For the third view, it is basically starting with a clean slate., so the annotationsToIgnore are back

A solution to this to change the order of the last two parts of the code above: first do the remove on super and then add all annotations. There is flickering, though, for the annotationsToIgnore

@ghost ghost assigned BotiKis Mar 4, 2012
@BotiKis
Copy link
Owner

BotiKis commented Mar 4, 2012

Thank you for your contribution!
I've pushed a version with your solution. I'll try to re implement this hole annotation adding once to completely remove the flickering.

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