[Pkg-javascript-commits] [leaflet-markercluster] 23/128: Merge branch 'master' into leaflet-master-merge
Jonas Smedegaard
dr at jones.dk
Sun Apr 16 06:26:00 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository leaflet-markercluster.
commit 97e27e173f69c7e3313fbdc02b4f3b8bcc887d37
Merge: 8ecc494 8221318
Author: danzel <danzel at localhost.geek.nz>
Date: Tue Dec 22 10:56:01 2015 +1300
Merge branch 'master' into leaflet-master-merge
Conflicts:
spec/suites/spiderfySpec.js
src/MarkerCluster.Spiderfier.js
README.md | 6 +-
spec/suites/spiderfySpec.js | 229 +++++++++++++++++++++++++++++++++++++++-
src/MarkerCluster.Spiderfier.js | 70 ++++++++----
src/MarkerClusterGroup.js | 21 ++--
4 files changed, 294 insertions(+), 32 deletions(-)
diff --cc spec/suites/spiderfySpec.js
index 6fdbabf,ff417d7..f2ffc77
--- a/spec/suites/spiderfySpec.js
+++ b/spec/suites/spiderfySpec.js
@@@ -114,10 -112,184 +114,184 @@@
marker.__parent.spiderfy();
- expect(marker._container.parentNode).to.be(map._pathRoot);
- expect(marker2._container.parentNode).to.be(map._pathRoot);
+ expect(marker._path.parentNode.parentNode.parentNode).to.be(map.getPane('overlayPane'));
+ expect(marker2._path.parentNode.parentNode.parentNode).to.be(map.getPane('overlayPane'));
});
+ it('Spiderfies at current zoom if all child markers are at the exact same position', function () {
+
+ 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 () {
+
+ 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);
+
+ });
+
+ it('removes all markers and spider legs when group is removed from map', function () {
+
+ 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);
+
+ marker.__parent.spiderfy();
+
+ expect(map._panes.markerPane.childNodes.length).to.be(3); // The 2 markers + semi-transparent cluster.
+ expect(map._pathRoot.childNodes.length).to.be(2); // The 2 spider legs.
+
+ });
+
+ it('adds then removes class "leaflet-cluster-anim" from mapPane on spiderfy', function () {
+
+ 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);
+
+ marker.__parent.spiderfy();
+
+ expect(map._panes.mapPane.className).to.contain('leaflet-cluster-anim');
+
+ clock.tick(1000);
+
+ expect(map._panes.mapPane.className).to.not.contain('leaflet-cluster-anim');
+
+ });
+
+ it('adds then removes class "leaflet-cluster-anim" from mapPane on unspiderfy', function () {
+
+ 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);
+
+ marker.__parent.spiderfy();
+
+ clock.tick(1000);
+
+ marker.__parent.unspiderfy();
+
+ expect(map._panes.mapPane.className).to.contain('leaflet-cluster-anim');
+
+ clock.tick(1000);
+
+ expect(map._panes.mapPane.className).to.not.contain('leaflet-cluster-anim');
+
+ });
+
+ it('fires unspiderfied event on unspiderfy', function (done) {
+
+ 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);
+
+ marker.__parent.spiderfy();
+
+ clock.tick(1000);
+
+ // Add event listener
+ group.on('unspiderfied', function (event) {
+ expect(event.target).to.be(group);
+ expect(event.cluster).to.be.a(L.Marker);
+ expect(event.markers[1]).to.be(marker);
+ expect(event.markers[0]).to.be(marker2);
+
+ done();
+ });
+
+ marker.__parent.unspiderfy();
+
+ clock.tick(1000);
+
+ });
+
+ it('does not leave class "leaflet-cluster-anim" on mapPane when group is removed while spiderfied', function () {
+
+ 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);
+
+ marker.__parent.spiderfy();
+
+ clock.tick(1000);
+
+ map.removeLayer(group);
+
+ expect(map._panes.mapPane.className).to.not.contain('leaflet-cluster-anim');
+
+ });
describe('zoomend event listener', function () {
diff --cc src/MarkerCluster.Spiderfier.js
index 197a20a,6b2f649..f6924e1
--- a/src/MarkerCluster.Spiderfier.js
+++ b/src/MarkerCluster.Spiderfier.js
@@@ -115,8 -113,11 +115,12 @@@ L.MarkerCluster.include(
delete m._spiderLeg;
}
}
-
+
+ group.fire('unspiderfied', {
+ cluster: this,
+ markers: childMarkers
+ });
+ group._ignoreMove = false;
group._spiderfied = null;
}
});
@@@ -153,9 -152,10 +157,12 @@@ L.MarkerClusterNonAnimated = L.MarkerCl
fg.addLayer(m);
}
this.setOpacity(0.3);
+
+ group._ignoreMove = false;
- group.fire('spiderfied');
+ group.fire('spiderfied', {
+ cluster: this,
+ markers: childMarkers
+ });
},
_animationUnspiderfy: function () {
@@@ -217,16 -216,18 +225,18 @@@ L.MarkerCluster.include(
}
// If it is a marker, add it now and we'll animate it out
- if (m.setOpacity) {
+ if (m.setZIndexOffset) {
m.setZIndexOffset(1000000); // Make normal markers appear on top of EVERYTHING
+ }
+ if (m.clusterHide) {
m.clusterHide();
+ }
-
+
+ // Vectors just get immediately added
- fg.addLayer(m);
+ fg.addLayer(m);
+ if (m._setPos) {
m._setPos(thisLayerPos);
- } else {
- // Vectors just get immediately added
- fg.addLayer(m);
}
}
@@@ -257,11 -258,12 +267,14 @@@
}
this.setOpacity(0.3);
+ group._ignoreMove = false;
+
setTimeout(function () {
group._animationEnd();
- group.fire('spiderfied');
+ group.fire('spiderfied', {
+ cluster: me,
+ markers: childMarkers
+ });
}, 200);
},
@@@ -272,9 -275,8 +286,9 @@@
thisLayerPos = zoomDetails ? map._latLngToNewLayerPoint(this._latlng, zoomDetails.zoom, zoomDetails.center) : map.latLngToLayerPoint(this._latlng),
childMarkers = this.getAllChildMarkers(),
svg = L.Path.SVG,
- m, i, leg, legPath, legLength;
+ m, i, leg, legPath, legLength, nonAnimatable;
+ group._ignoreMove = true;
group._animationStart();
//Make us visible and bring the child markers back in
@@@ -419,9 -426,11 +447,11 @@@ L.MarkerClusterGroup.include(
if (layer._spiderLeg) {
this._featureGroup.removeLayer(layer);
- if (layer.setOpacity) {
- layer.setOpacity(1);
+ if (layer.clusterShow) {
+ layer.clusterShow();
+ }
- //Position will be fixed up immediately in _animationUnspiderfy
+ //Position will be fixed up immediately in _animationUnspiderfy
+ if (layer.setZIndexOffset) {
layer.setZIndexOffset(0);
}
--
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