Clustering sometimes changes when changing region coordinates, but not zoom level
Opened this issue · 8 comments
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.
Does this recipe help?
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.
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?
@choefele, sorry for the late reply as well. I'll get a PR working within this week. :)
@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 ?
Also, if setCenterCoordinate:animated:
is buggy, so that it needs that workaround, wouldn't this line be a problem ?
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
I think there are several issues with selectAnnotation:andZoomToRegionWithLatitudinalMeters:longitudinalMeters:
- Given a set level of zoom there's no way to select between different annotations without changing the clustering.
- If called repeatedly, when the map is still animating from a previous call, the map ends up in the middle of the ocean.
- 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.