[Pkg-javascript-commits] [leaflet-markercluster] 455/479: If fitBounds wouldn't zoom us down, zoom us down instead. Fixes #144

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:01:07 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 957a69dc2b2c482df634f7e7990f24105e4cf725
Author: danzel <danzel at localhost.geek.nz>
Date:   Wed Dec 18 09:26:25 2013 +1300

    If fitBounds wouldn't zoom us down, zoom us down instead. Fixes #144
---
 src/MarkerCluster.js | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/MarkerCluster.js b/src/MarkerCluster.js
index 0663c47..a3a7d67 100644
--- a/src/MarkerCluster.js
+++ b/src/MarkerCluster.js
@@ -48,8 +48,10 @@ L.MarkerCluster = L.Marker.extend({
 			map = this._group._map,
 			boundsZoom = map.getBoundsZoom(this._bounds),
 			zoom = this._zoom + 1,
+			mapZoom = map.getZoom(),
 			i;
 
+		//calculate how fare we need to zoom down to see all of the markers
 		while (childClusters.length > 0 && boundsZoom > zoom) {
 			zoom++;
 			var newClusters = [];
@@ -61,6 +63,8 @@ L.MarkerCluster = L.Marker.extend({
 
 		if (boundsZoom > zoom) {
 			this._group._map.setView(this._latlng, zoom);
+		} else if (boundsZoom <= mapZoom) { //If fitBounds wouldn't zoom us down, zoom us down instead
+			this._group._map.setView(this._latlng, mapZoom + 1);
 		} else {
 			this._group._map.fitBounds(this._bounds);
 		}

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