From 6ebc38b785ab5f09ecd8692b96608aab841ca374 Mon Sep 17 00:00:00 2001 From: p-a-s-c-a-l Date: Thu, 23 Jan 2020 11:41:21 +0100 Subject: [PATCH] make exclusive groups deselectable --- dist/leaflet.groupedlayercontrol.min.js | 6 +++--- dist/leaflet.groupedlayercontrol.min.js.map | 2 +- src/leaflet.groupedlayercontrol.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/leaflet.groupedlayercontrol.min.js b/dist/leaflet.groupedlayercontrol.min.js index a6693f9..8fc1c8a 100644 --- a/dist/leaflet.groupedlayercontrol.min.js +++ b/dist/leaflet.groupedlayercontrol.min.js @@ -1,5 +1,5 @@ -/*! Version: 0.6.1 -Date: 2018-04-30 */ +/*! Version: 0.7.0 +Date: 2020-01-23 */ -L.Control.GroupedLayers=L.Control.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,exclusiveGroups:[],groupCheckboxes:!1},initialize:function(a,b,c){var d,e;L.Util.setOptions(this,c),this._layers=[],this._lastZIndex=0,this._handlingClick=!1,this._groupList=[],this._domGroups=[];for(d in a)this._addLayer(a[d],d);for(d in b)for(e in b[d])this._addLayer(b[d][e],e,d,!0)},onAdd:function(a){return this._initLayout(),this._update(),a.on("layeradd",this._onLayerChange,this).on("layerremove",this._onLayerChange,this),this._container},onRemove:function(a){a.off("layeradd",this._onLayerChange,this).off("layerremove",this._onLayerChange,this)},addBaseLayer:function(a,b){return this._addLayer(a,b),this._update(),this},addOverlay:function(a,b,c){return this._addLayer(a,b,c,!0),this._update(),this},removeLayer:function(a){var b=L.Util.stamp(a),c=this._getLayer(b);return c&&delete this._layers[this._layers.indexOf(c)],this._update(),this},_getLayer:function(a){for(var b=0;ba;a++)b=e[a],b.groupID===this.groupID&&"leaflet-control-layers-selector"===b.className&&(b.checked=this.checked,c=d._getLayer(b.layerId),b.checked&&!d._map.hasLayer(c.layer)?d._map.addLayer(c.layer):!b.checked&&d._map.hasLayer(c.layer)&&d._map.removeLayer(c.layer));d._handlingClick=!1},_onInputClick:function(){var a,b,c,d=this._form.getElementsByTagName("input"),e=d.length;for(this._handlingClick=!0,a=0;e>a;a++)b=d[a],"leaflet-control-layers-selector"===b.className&&(c=this._getLayer(b.layerId),b.checked&&!this._map.hasLayer(c.layer)?this._map.addLayer(c.layer):!b.checked&&this._map.hasLayer(c.layer)&&this._map.removeLayer(c.layer));this._handlingClick=!1},_expand:function(){L.DomUtil.addClass(this._container,"leaflet-control-layers-expanded");var a=this._map._size.y-4*this._container.offsetTop;ac;c++)if(a[c]===b)return c;return-1}}),L.control.groupedLayers=function(a,b,c){return new L.Control.GroupedLayers(a,b,c)}; +L.Control.GroupedLayers=L.Control.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,exclusiveGroups:[],groupCheckboxes:!1},initialize:function(e,t,a){var r,i;for(r in L.Util.setOptions(this,a),this._layers=[],this._lastZIndex=0,this._handlingClick=!1,this._groupList=[],this._domGroups=[],e)this._addLayer(e[r],r);for(r in t)for(i in t[r])this._addLayer(t[r][i],i,r,!0)},onAdd:function(e){return this._initLayout(),this._update(),e.on("layeradd",this._onLayerChange,this).on("layerremove",this._onLayerChange,this),this._container},onRemove:function(e){e.off("layeradd",this._onLayerChange,this).off("layerremove",this._onLayerChange,this)},addBaseLayer:function(e,t){return this._addLayer(e,t),this._update(),this},addOverlay:function(e,t,a){return this._addLayer(e,t,a,!0),this._update(),this},removeLayer:function(e){var t=L.Util.stamp(e),a=this._getLayer(t);return a&&delete this._layers[this._layers.indexOf(a)],this._update(),this},_getLayer:function(e){for(var t=0;t