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

Spiderfy at current zoom if all child markers still in single cluster at maxZoom #606

Merged
merged 4 commits into from
Nov 26, 2015

Conversation

ghybs
Copy link
Contributor

@ghybs ghybs commented Nov 25, 2015

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.

to spiderfy as soon as all child markers are contained in a single cluster, from map._maxZoom to the clicked cluster.
Crawl down child clusters instead of requesting all child markers to pick the first one, as requesting all child markers crawls down all child clusters recursively...
to check that spiderfying at current zoom works if all child markers are at the exact same position, AND in the case they are at slightly different position but still in 1 cluster at maxZoom.

Also slightly improved again clawling to bottom cluster in _zoomOrSpiderfy: stop as soon as there is more than 1 child cluster (or no child cluster).
danzel added a commit that referenced this pull request Nov 26, 2015
…luster

Spiderfy at current zoom if all child markers still in single cluster at maxZoom
@danzel danzel merged commit 9a212d1 into Leaflet:master Nov 26, 2015
@danzel
Copy link
Member

danzel commented Nov 26, 2015

Good stuff :)

@ghybs ghybs deleted the spiderfyOnAllChildrenInBottomMostCluster branch November 27, 2015 10:52
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

Successfully merging this pull request may close these issues.

2 participants