leaflet-boundsawarelayergroup
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -16,2 +16,3 @@ /* | ||
var originalInit = L.LayerGroup.prototype.initialize; | ||
var originalOnRemove = L.LayerGroup.prototype.onRemove; | ||
@@ -45,5 +46,3 @@ L.LayerGroup.include({ | ||
this._addForBounds(this._layers, map); | ||
map.on('moveend', function () { | ||
this._addForBounds(this._layers, map); | ||
}, this); | ||
map.on('moveend', this._onMapMoveEnd, this); | ||
} else { | ||
@@ -54,2 +53,11 @@ this.eachLayer(map.addLayer, map); | ||
onRemove: function (map) { | ||
originalOnRemove.call(this, map); | ||
map.off('moveend', this._onMapMoveEnd, this); | ||
}, | ||
_onMapMoveEnd: function () { | ||
this._addForBounds(this._layers, this._map); | ||
}, | ||
_addForBounds: function (layerArray, map) { | ||
@@ -56,0 +64,0 @@ var mapBounds = map.getBounds(), intersectsMapBounds, layer, i; |
@@ -8,2 +8,2 @@ /* | ||
*/ | ||
!function(a){var b={makeBoundsAware:!1},c=a.LayerGroup.prototype.initialize;a.LayerGroup.include({initialize:function(d,e){a.setOptions(this,b),a.setOptions(this,e),c.call(this,d)},addLayer:function(a){var b=this.getLayerId(a);return this._layers[b]=a,this._map&&(this.options.makeBoundsAware===!0?this._addForBounds([a],this._map):this._map.addLayer(a)),this},onAdd:function(a){this._map=a,this.options.makeBoundsAware===!0?(this._addForBounds(this._layers,a),a.on("moveend",function(){this._addForBounds(this._layers,a)},this)):this.eachLayer(a.addLayer,a)},_addForBounds:function(a,b){var c,d,e,f=b.getBounds();for(e in a)d=a[e],c=!0,"function"==typeof d.getLatLng?f.contains(d.getLatLng())||(c=!1):"function"==typeof d.getBounds&&(f.intersects(d.getBounds())||(c=!1)),c?b.addLayer(d):b.removeLayer(d)}}),a.layerGroup=function(b,c){return new a.LayerGroup(b,c)},a.featureGroup=function(b,c){return new a.FeatureGroup(b,c)}}(L); | ||
!function(a){var b={makeBoundsAware:!1},c=a.LayerGroup.prototype.initialize,d=a.LayerGroup.prototype.onRemove;a.LayerGroup.include({initialize:function(d,e){a.setOptions(this,b),a.setOptions(this,e),c.call(this,d)},addLayer:function(a){var b=this.getLayerId(a);return this._layers[b]=a,this._map&&(this.options.makeBoundsAware===!0?this._addForBounds([a],this._map):this._map.addLayer(a)),this},onAdd:function(a){this._map=a,this.options.makeBoundsAware===!0?(this._addForBounds(this._layers,a),a.on("moveend",this._onMapMoveEnd,this)):this.eachLayer(a.addLayer,a)},onRemove:function(a){d.call(this,a),a.off("moveend",this._onMapMoveEnd,this)},_onMapMoveEnd:function(){this._addForBounds(this._layers,this._map)},_addForBounds:function(a,b){var c,d,e,f=b.getBounds();for(e in a)d=a[e],c=!0,"function"==typeof d.getLatLng?f.contains(d.getLatLng())||(c=!1):"function"==typeof d.getBounds&&(f.intersects(d.getBounds())||(c=!1)),c?b.addLayer(d):b.removeLayer(d)}}),a.layerGroup=function(b,c){return new a.LayerGroup(b,c)},a.featureGroup=function(b,c){return new a.FeatureGroup(b,c)}}(L); |
{ | ||
"name": "leaflet-boundsawarelayergroup", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Leaflet.LayerGroup plugin to render only layers in the current map bounds", | ||
@@ -5,0 +5,0 @@ "main": "dist/leaflet.boundsawarelayergroup.js", |
@@ -6,2 +6,3 @@ var defaultOptions = { | ||
var originalInit = L.LayerGroup.prototype.initialize; | ||
var originalOnRemove = L.LayerGroup.prototype.onRemove; | ||
@@ -35,5 +36,3 @@ L.LayerGroup.include({ | ||
this._addForBounds(this._layers, map); | ||
map.on('moveend', function () { | ||
this._addForBounds(this._layers, map); | ||
}, this); | ||
map.on('moveend', this._onMapMoveEnd, this); | ||
} else { | ||
@@ -44,2 +43,11 @@ this.eachLayer(map.addLayer, map); | ||
onRemove: function (map) { | ||
originalOnRemove.call(this, map); | ||
map.off('moveend', this._onMapMoveEnd, this); | ||
}, | ||
_onMapMoveEnd: function () { | ||
this._addForBounds(this._layers, this._map); | ||
}, | ||
_addForBounds: function (layerArray, map) { | ||
@@ -46,0 +54,0 @@ var mapBounds = map.getBounds(), intersectsMapBounds, layer, i; |
19390
419