[Pkg-javascript-commits] [leaflet-markercluster] 182/219: Improved _zoomOrSpiderfy

Jonas Smedegaard dr at jones.dk
Sat May 7 09:39:32 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 8e2e653ac0294ec63fb5f888e0d1bee74d5e8383
Author: ghybs <ghybs1 at gmail.com>
Date:   Tue Nov 24 17:46:41 2015 +0400

    Improved _zoomOrSpiderfy
    
    to spiderfy as soon as all child markers are contained in a single cluster, from map._maxZoom to the clicked cluster.
---
 src/MarkerClusterGroup.js | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 32fe28c..a2e5cd4 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -709,17 +709,17 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 	},
 
 	_zoomOrSpiderfy: function (e) {
-		var map = this._map;
-		if (e.layer._bounds._northEast.equals(e.layer._bounds._southWest)) {
-			if (this.options.spiderfyOnMaxZoom) {
-				e.layer.spiderfy();
-			}
-		} else if (map.getMaxZoom() === map.getZoom()) {
+		var map = this._map,
+		    cluster = e.layer,
+		    someChildMarkerParent = cluster.getAllChildMarkers()[0].__parent;
+
+		if (someChildMarkerParent._zoom === map.getMaxZoom() && someChildMarkerParent._childCount === cluster._childCount) {
+			// All child markers are contained in a single cluster from map._maxZoom to this cluster.
 			if (this.options.spiderfyOnMaxZoom) {
-				e.layer.spiderfy();
+				cluster.spiderfy();
 			}
 		} else if (this.options.zoomToBoundsOnClick) {
-			e.layer.zoomToBounds();
+			cluster.zoomToBounds();
 		}
 
 		// Focus the map again for keyboard users.

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