[Pkg-javascript-commits] [leaflet-markercluster] 269/479: Replace _getExpandedVisibleBounds with lat/lng diff implementation as provided by andersarstrand in #74. Should improve behaviour with custom projections

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:38 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 7eaef8530af3c5dac9f23c188f3bdae1cf26a926
Author: danzel <danzel at localhost.geek.nz>
Date:   Wed Oct 17 09:49:35 2012 +1300

    Replace _getExpandedVisibleBounds with lat/lng diff implementation as provided by andersarstrand in #74. Should improve behaviour with custom projections
---
 src/MarkerClusterGroup.js | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index ac80665..cf4434b 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -589,13 +589,15 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 	//Gets the maps visible bounds expanded in each direction by the size of the screen (so the user cannot see an area we do not cover in one pan)
 	_getExpandedVisibleBounds: function () {
 		var map = this._map,
-			bounds = map.getPixelBounds(),
-			width =  L.Browser.mobile ? 0 : Math.abs(bounds.max.x - bounds.min.x),
-			height = L.Browser.mobile ? 0 : Math.abs(bounds.max.y - bounds.min.y),
-			sw = map.unproject(new L.Point(bounds.min.x - width, bounds.min.y - height)),
-			ne = map.unproject(new L.Point(bounds.max.x + width, bounds.max.y + height));
-
-		return new L.LatLngBounds(sw, ne);
+			bounds = map.getBounds(),
+			sw = bounds._southWest,
+			ne = bounds._northEast,
+			latDiff = L.Browser.mobile ? 0 : Math.abs(sw.lat - ne.lat),
+			lngDiff = L.Browser.mobile ? 0 : Math.abs(sw.lng - ne.lng);
+
+		return new L.LatLngBounds(
+			new L.LatLng(sw.lat - latDiff, sw.lng - lngDiff, true),
+			new L.LatLng(ne.lat + latDiff, ne.lng + lngDiff, true));
 	},
 
 	//Shared animation code

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