Skip to content

Commit

Permalink
fixed layer's control
Browse files Browse the repository at this point in the history
  • Loading branch information
SVoyt committed Oct 27, 2016
1 parent c40e791 commit ebf21a6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 44 deletions.
33 changes: 12 additions & 21 deletions dist/leaflet-spectrum-spatial.js
Expand Up @@ -2959,10 +2959,8 @@ L.Control.include(L.Evented.prototype);

hideLegendForLayer: function(layerId) {
var lo = this._getLayer(layerId);
if(!this.options.legendContainer) {
if(lo.legendContainer.hasChildNodes()) {
L.DomUtil.empty(lo.legendContainer);
}
if ((!this.options.legendContainer) && (lo.legendContainer.hasChildNodes())) {
L.DomUtil.empty(lo.legendContainer);
}
},

Expand Down Expand Up @@ -3186,19 +3184,14 @@ L.Control.include(L.Evented.prototype);
var layerId = e.currentTarget.layerId;
var lo = this._getLayer(layerId);
var legend;
if(!this.options.legendContainer) {
if(lo.legendContainer.hasChildNodes()) {
L.DomUtil.empty(lo.legendContainer);
}
else {
legend = new L.SpectrumSpatial.Controls.Legend(lo.layer._service, lo.layer._mapName, this.options.legendOptions);
legend.addTo(this._map, this.options.legendContainer ? this.options.legendContainer : lo.legendContainer);
}
}
else {
legend = new L.SpectrumSpatial.Controls.Legend(lo.layer._service, lo.layer._mapName, this.options.legendOptions);
legend.addTo(this._map, this.options.legendContainer ? this.options.legendContainer : lo.legendContainer);

if ((!this.options.legendContainer) && (lo.legendContainer.hasChildNodes())) {
L.DomUtil.empty(lo.legendContainer);
return;
}

legend = new L.SpectrumSpatial.Controls.Legend(lo.layer._service, lo.layer._mapName, this.options.legendOptions);
legend.addTo(this._map, this.options.legendContainer ? this.options.legendContainer : lo.legendContainer);
},

_onDownClick: function(e) {
Expand Down Expand Up @@ -3269,11 +3262,13 @@ L.Control.include(L.Evented.prototype);
}

this._refocusOnMap();
this._fireVisibilityChangedEvent({

this.fire('visibilitychanged', {
removedLayers: removedLayers,
addedLayers: addedLayers,
activeLayers: activeLayers
});

this._handlingClick = false;
},

Expand All @@ -3295,10 +3290,6 @@ L.Control.include(L.Evented.prototype);
this._handlingClick = false;
},

_fireVisibilityChangedEvent: function(layers) {
this._map.fire('spectrum:visibility-changed', layers);
},

_expand: function() {
L.DomUtil.addClass(this._container, this.className + '-expanded');
},
Expand Down

0 comments on commit ebf21a6

Please sign in to comment.