[Pkg-javascript-commits] [leaflet-markercluster] 448/479: Fix incorrectly adding parent clusters when doing a big move that changes zoom levels. Fixes #281

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:01:06 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository leaflet-markercluster.

commit 53eab49a7ecac32218c6d5e6dbba15ca7e80558b
Author: danzel <danzel at localhost.geek.nz>
Date:   Fri Dec 6 13:34:43 2013 +1300

    Fix incorrectly adding parent clusters when doing a big move that changes zoom levels. Fixes #281
---
 spec/suites/zoomAnimationSpec.js | 34 ++++++++++++++++++++++++++++++++--
 src/MarkerClusterGroup.js        |  2 +-
 2 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/spec/suites/zoomAnimationSpec.js b/spec/suites/zoomAnimationSpec.js
index 7fb8e29..dbf60f9 100644
--- a/spec/suites/zoomAnimationSpec.js
+++ b/spec/suites/zoomAnimationSpec.js
@@ -16,7 +16,7 @@
 		document.body.removeChild(div);
 	});
 
-	it('adds the visible marker to the map', function () {
+	it('adds the visible marker to the map when zooming in', function () {
 		map.setView(new L.LatLng(-37.36142550190516, 174.254150390625), 7);
 
 		var markers = new L.MarkerClusterGroup({
@@ -39,7 +39,7 @@
 		expect(marker._icon).to.not.be(null);
 	});
 
-	it('adds the visible marker to the map', function () {
+	it('adds the visible marker to the map when jumping around', function () {
 
 		var markers = new L.MarkerClusterGroup();
 		var marker1 = new L.Marker([48.858280181884766, 2.2945759296417236]);
@@ -62,4 +62,34 @@
 		expect(marker2._icon).to.not.be(undefined);
 		expect(marker2._icon).to.not.be(null);
 	});
+
+	it('adds the visible markers to the map, but not parent clusters when jumping around', function () {
+
+		var markers = new L.MarkerClusterGroup(),
+			marker1 = new L.Marker([59.9520, 30.3307]),
+			marker2 = new L.Marker([59.9516, 30.3308]),
+			marker3 = new L.Marker([59.9513, 30.3312]);
+
+		markers.addLayer(marker1);
+		markers.addLayer(marker2);
+		markers.addLayer(marker3);
+		map.addLayer(markers);
+
+		//Show none of them
+		map.setView([53.0676, 170.6835], 16);
+
+		clock.tick(1000);
+
+		//Zoom so that all the markers will be visible (Same as zoomToShowLayer)
+		map.setView(marker1.getLatLng(), 18);
+
+		//Run the the animation
+		clock.tick(1000);
+
+		//Now the markers should all be visible, and there should be no visible clusters
+		expect(marker1._icon.parentNode).to.be(map._panes.markerPane);
+		expect(marker2._icon.parentNode).to.be(map._panes.markerPane);
+		expect(marker3._icon.parentNode).to.be(map._panes.markerPane);
+		expect(map._panes.markerPane.childNodes.length).to.be(3);
+	});
 });
\ No newline at end of file
diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 5196ecb..cc8efdd 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -656,7 +656,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		var newBounds = this._getExpandedVisibleBounds();
 
 		this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._zoom, newBounds);
-		this._topClusterLevel._recursivelyAddChildrenToMap(null, this._zoom, newBounds);
+		this._topClusterLevel._recursivelyAddChildrenToMap(null, this._map._zoom, newBounds);
 
 		this._currentShownBounds = newBounds;
 		return;

-- 
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