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

Clustering sometimes changes when changing region coordinates, but not zoom level #119

Open
kusamakura opened this issue Jan 15, 2016 · 8 comments

Comments

@kusamakura
Copy link

Sometimes when changing the map view's center region, the update annotation sequence triggers (namely, in CCHMapClusterController's mapView:regionDidChangeAnimated:). This is due to the longitude delta check. Since calculating the zoom level is already included in this project, wouldn't it be better to use that instead? I have a fork which does just that, and I set the epsilon/difference threshold to a value to something small enough, but not too small to trigger a 'zoom change' when changing the region center.

@choefele
Copy link
Owner

Does this recipe help?

@kusamakura
Copy link
Author

I used it before, but changing the clusters on the same zoom level (even when using the same region span, updateAnnotations would still get triggered) is not desirable for my use case. So I'm not actually sure if this is a bug, since what happens is contrary to what's intended – in the comments, at least.

@choefele
Copy link
Owner

Sorry for the late reply. Might be a good idea to use CCHMapClusterControllerZoomLevelForRegion with a small delta to decide if the map has been zoomed.

Would you mind creating a pull request and trying out if this works?

@kusamakura
Copy link
Author

@choefele, sorry for the late reply as well. I'll get a PR working within this week. :)

@bhapca
Copy link

bhapca commented Jun 3, 2016

@choefele is there an equivalent of the recipe that you mentioned above for when when trying to select an annotation with selectAnnotation:andZoomToRegionWithLatitudinalMeters:longitudinalMeters:?

Otherwise, selecting an annotation programatically would most of the times change clustering, even when zooming didn't change.

I tried tried to use CLLocationDistance MKMetersBetweenMapPoints ( MKMapPoint a, MKMapPoint b ) to compute the latitudinalMeters and longitudinalMeters from the visibleMapRect, but it still sees it as a zoom.

I did some experiments at bhapca@2988453 and bhapca@4e57c75 to provide a way of selecting without zooming. Is there a way to achieve the equivalent behaviour with the current API ?

@bhapca
Copy link

bhapca commented Jun 3, 2016

Also, if setCenterCoordinate:animated: is buggy, so that it needs that workaround, wouldn't this line be a problem ?

@choefele
Copy link
Owner

choefele commented Jun 6, 2016

The code to select an annotation assumes that some zooming will happen anyway. I haven't worked on this behaviour for a while, so I don't know any workarounds

@bhapca
Copy link

bhapca commented Jun 7, 2016

I think there are several issues with selectAnnotation:andZoomToRegionWithLatitudinalMeters:longitudinalMeters:

  1. Given a set level of zoom there's no way to select between different annotations without changing the clustering.
  2. If called repeatedly, when the map is still animating from a previous call, the map ends up in the middle of the ocean.
  3. If called repeatedly, after the animation from the previous call has settled, you may get errors like "ERROR: Trying to select an annotation which has not been added", at random.

These all can be seen with a change to the sample app that I made at:
https://github.com/bhapca/CCHMapClusterController/tree/select-annotation-issues. It simply provides a way to swap the selection between 2 annotations at the East and West sides of Berlin.

I placed a potential fix for all these issues on https://github.com/bhapca/CCHMapClusterController/tree/select-annotation-issues-fix, and created the PR at #126, if you wish to bring them into master.

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

No branches or pull requests

3 participants