Replace _getExpandedVisibleBounds with lat/lng diff implementation as provided by andersarstrand in #74. Should improve behaviour with custom projections

This commit is contained in:
danzel
2012-10-17 09:49:35 +13:00
parent 6f5ee732b0
commit 7eaef8530a
+8 -6
View File
@@ -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));
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(sw, ne);
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