diff --git a/src/controls/legend/overlayproperties.js b/src/controls/legend/overlayproperties.js index 488b01c32..c96294aea 100644 --- a/src/controls/legend/overlayproperties.js +++ b/src/controls/legend/overlayproperties.js @@ -129,7 +129,10 @@ const OverlayProperties = function OverlayProperties(options = {}) { buttonIconCls: 'black', ariaLabel: 'Välj stil' }); - const components = [transparencySlider, legendComponent]; + const components = [legendComponent]; + if (opacityControl) { + components.push(transparencySlider); + } if (hasStylePicker()) { components.push(styleSelection); } @@ -141,12 +144,12 @@ const OverlayProperties = function OverlayProperties(options = {}) { onRender() { viewer.getControlByName('legend').dispatch('renderOverlayProperties', { cmp: this, layer }); this.dispatch('render'); - sliderEl = document.getElementById(transparencySlider.getId()); overlayEl = document.getElementById(this.getId()); overlayEl.addEventListener('click', (e) => { this.dispatch('click', e); }); if (opacityControl) { + sliderEl = document.getElementById(transparencySlider.getId()); sliderEl.nextElementSibling.value *= 100; sliderEl.addEventListener('input', () => { layer.setOpacity(sliderEl.valueAsNumber); @@ -169,7 +172,7 @@ const OverlayProperties = function OverlayProperties(options = {}) {