[Pkg-javascript-commits] [leaflet-markercluster] 246/479: Improve behaviour of zoomToShowLayer. Fixes #65

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:36 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 7927289adb0e7d6ffe3c89d55198fd67443b99ce
Author: danzel <danzel at localhost.geek.nz>
Date:   Thu Sep 20 11:22:24 2012 +1200

    Improve behaviour of zoomToShowLayer. Fixes #65
---
 src/MarkerClusterGroup.js | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 8286bc8..905c872 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -180,12 +180,18 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 			}
 		};
 
-		if ((layer._icon || layer.__parent._icon) && this._map.getBounds().contains(layer.__parent._latlng)) {
-			//Layer or cluster is already visible
-			showMarker.call(this);
+		if (layer._icon) {
+			callback();
+		} else if (layer.__parent._zoom < this._map.getZoom()) {
+			//Layer should be visible now but isn't on screen, just pan over to it
+			this._map.on('moveend', showMarker, this);
+			if (!layer._icon) {
+				map.panTo(layer.getLatLng());
+			}
 		} else {
 			this._map.on('moveend', showMarker, this);
 			this.on('animationend', showMarker, this);
+			map.setView(layer.getLatLng(), layer.__parent._zoom + 1);
 			layer.__parent.zoomToBounds();
 		}
 	},

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