[Pkg-javascript-commits] [leaflet-markercluster] 184/219: Added spiderfy test for current zoom
Jonas Smedegaard
dr at jones.dk
Sat May 7 09:39:33 UTC 2016
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository leaflet-markercluster.
commit cf2f310d2352016a89e62bac08acbf386e6bca59
Author: ghybs <ghybs1 at gmail.com>
Date: Wed Nov 25 17:26:17 2015 +0400
Added spiderfy test for current zoom
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).
---
spec/suites/spiderfySpec.js | 62 +++++++++++++++++++++++++++++++++++++++++++++
src/MarkerClusterGroup.js | 4 +--
2 files changed, 64 insertions(+), 2 deletions(-)
diff --git a/spec/suites/spiderfySpec.js b/spec/suites/spiderfySpec.js
index 366bf1a..141304b 100644
--- a/spec/suites/spiderfySpec.js
+++ b/spec/suites/spiderfySpec.js
@@ -68,6 +68,68 @@
expect(marker2._container.parentNode).to.be(map._pathRoot);
});
+ it('Spiderfies at current zoom if all child markers are at the exact same position', function () {
+
+ var group = new L.MarkerClusterGroup();
+ var marker = new L.Marker([1.5, 1.5]);
+ var marker2 = new L.Marker([1.5, 1.5]);
+
+ group.addLayers([marker, marker2]);
+ map.addLayer(group);
+
+ // Get the appropriate cluster.
+ var cluster = marker.__parent,
+ zoom = map.getZoom();
+
+ while (cluster._zoom !== zoom) {
+ cluster = cluster.__parent;
+ }
+
+ expect(zoom).to.be.lessThan(10);
+
+ cluster.fireEvent('click');
+
+ clock.tick(1000);
+
+ expect(map.getZoom()).to.equal(zoom);
+
+ expect(marker._icon.parentNode).to.be(map._panes.markerPane);
+ expect(marker2._icon.parentNode).to.be(map._panes.markerPane);
+
+ });
+
+ it('Spiderfies at current zoom if all child markers are still within a single cluster at map maxZoom', function () {
+
+ var group = new L.MarkerClusterGroup();
+ var marker = new L.Marker([1.5, 1.50001]);
+ var marker2 = new L.Marker([1.5, 1.5]);
+
+ group.addLayers([marker, marker2]);
+ map.addLayer(group);
+
+ expect(marker.__parent._zoom).to.equal(18);
+
+ // Get the appropriate cluster.
+ var cluster = marker.__parent,
+ zoom = map.getZoom();
+
+ while (cluster._zoom !== zoom) {
+ cluster = cluster.__parent;
+ }
+
+ expect(zoom).to.be.lessThan(10);
+
+ cluster.fireEvent('click');
+
+ clock.tick(1000);
+
+ expect(map.getZoom()).to.equal(zoom);
+
+ expect(marker._icon.parentNode).to.be(map._panes.markerPane);
+ expect(marker2._icon.parentNode).to.be(map._panes.markerPane);
+
+ });
+
describe('zoomend event listener', function () {
it('unspiderfies correctly', function () {
diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 6fee067..a6ba8df 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -713,9 +713,9 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
cluster = e.layer,
bottomCluster = cluster;
- while (bottomCluster._childClusters.length) {
+ while (bottomCluster._childClusters.length === 1) {
bottomCluster = bottomCluster._childClusters[0];
- } // bottomCluster is not necessarily the bottom-most one, but in that case we should not spiderfy anyway.
+ }
if (bottomCluster._zoom === map.getMaxZoom() && bottomCluster._childCount === cluster._childCount) {
// All child markers are contained in a single cluster from map._maxZoom to this cluster.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/leaflet-markercluster.git
More information about the Pkg-javascript-commits
mailing list