diff --git a/contribs/gmf/src/backgroundlayerselector/component.js b/contribs/gmf/src/backgroundlayerselector/component.js index 5609aebd5387..f8c04af27add 100644 --- a/contribs/gmf/src/backgroundlayerselector/component.js +++ b/contribs/gmf/src/backgroundlayerselector/component.js @@ -206,6 +206,7 @@ Controller.prototype.handleThemesChange_ = function() { Controller.prototype.getSetBgLayerOpacity = function(val) { if (val !== undefined) { this.opacityLayer.setOpacity(val); + this.opacityLayer.setVisible(val !== 0); } return this.opacityLayer.getOpacity(); }; diff --git a/src/map/BackgroundLayerMgr.js b/src/map/BackgroundLayerMgr.js index 51c102d67fe4..4121cea91ed6 100644 --- a/src/map/BackgroundLayerMgr.js +++ b/src/map/BackgroundLayerMgr.js @@ -163,8 +163,9 @@ export class MapBackgroundLayerManager extends olObservable { const bgGroup = this.ngeoLayerHelper_.getGroupFromMap(map, BACKGROUNDLAYERGROUP_NAME); const previous = bgGroup.getLayers().remove(this.getOpacityBgLayer(map)); const ZIndex = -100; - layer.setOpacity(previous ? previous.getOpacity() : 0); - layer.setVisible(previous ? previous.getVisible() : true); + const opacity = previous ? previous.getOpacity() : 0; + layer.setOpacity(opacity); + layer.setVisible(opacity !== 0); layer.setZIndex(ZIndex); this.ngeoLayerHelper_.setZIndexToFirstLevelChildren(layer, ZIndex);