Spiderfy at current zoom if all child markers still in single cluster at maxZoom #606
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Current code in
_zoomOrSpiderfy
spiderfies at current zoom only if all child markers are at the exact same position (i.e. cluster bounds is a point) (or if we are at max zoom already obviously).That means that if markers are at slightly different positions, but if they are all still in a single cluster at maximum zoom, clicking on the cluster will zoom to that max zoom level, but user will still see the "same" cluster, and no markers. And he/she will need a second click to trigger the spiderfy. This is exactly what the current code was trying to avoid.
Since current MCG does not display any clue about the true markers position anyway (spider legs point at the cluster position, not at true positions), there is no point zooming to maximum zoom in that case either.
This PR checks if all child markers are still within a single cluster at maximum zoom, instead of checking for cluster bounds being a point.
Demo of the 2 different behaviours here: http://jsfiddle.net/ve2huzxw/50/
I also included 2 extra tests in spiderfierSpec test suite to cover these cases.