From 1d4343bc6cd5caf96746d418dba7ef45d214883c Mon Sep 17 00:00:00 2001 From: Jonas Date: Fri, 6 Dec 2024 12:57:08 +0100 Subject: [PATCH 1/5] Update overlays.js --- src/controls/legend/overlays.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/controls/legend/overlays.js b/src/controls/legend/overlays.js index 552dbae1d..e204f0c93 100644 --- a/src/controls/legend/overlays.js +++ b/src/controls/legend/overlays.js @@ -133,10 +133,11 @@ const Overlays = function Overlays(options) { // Hide overlays container when empty const onChangeLayer = function onChangeLayer() { - const oldNrOverlays = overlays.length; const nrOverlays = readOverlays().length; - if (oldNrOverlays !== nrOverlays && nrOverlays < 2 && oldNrOverlays < 2) { - document.getElementById(this.getId()).classList.toggle('hidden'); + if(nrOverlays === 0){ + document.getElementById(this.getId()).classList.add('hidden'); + } else { + document.getElementById(this.getId()).classList.remove('hidden'); } }; From 2b135061f3277ef95a7129169383eee86613323b Mon Sep 17 00:00:00 2001 From: Jonas Date: Fri, 6 Dec 2024 13:18:47 +0100 Subject: [PATCH 2/5] Update legend.js --- src/controls/legend.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/controls/legend.js b/src/controls/legend.js index 2d0c48732..592a3de34 100644 --- a/src/controls/legend.js +++ b/src/controls/legend.js @@ -223,6 +223,7 @@ const Legend = function Legend(options = {}) { const setVisibleLayersViewActive = function setVisibleLayersViewActive(active) { if (!visibleLayersControl) return; visibleLayersViewActive = active; + overlaysCmp.readOverlays() if (visibleLayersViewActive) { document.getElementById(overlaysCmp.getId()).classList.add('hidden'); document.getElementById(visibleOverlaysCmp.getId()).classList.remove('hidden'); @@ -231,7 +232,10 @@ const Legend = function Legend(options = {}) { visibleOverlaysCmp.dispatch('readOverlays'); document.getElementById(toolsCmp.getId()).classList.add('hidden'); } else { - document.getElementById(overlaysCmp.getId()).classList.remove('hidden'); + const nrOverlays = overlaysCmp.readOverlays().length; + if(nrOverlays > 0){ + document.getElementById(overlaysCmp.getId()).classList.remove('hidden'); + } document.getElementById(visibleOverlaysCmp.getId()).classList.add('hidden'); document.getElementById(showAllVisibleLayersButton.getId()).classList.add('hidden'); document.getElementById(showVisibleLayersButton.getId()).classList.remove('hidden'); @@ -720,8 +724,7 @@ const Legend = function Legend(options = {}) { cls: 'flex column relative', components: mainContainerComponents, style: { - 'max-height': `${maxHeight}px`, - width: 'min-content' + 'max-height': `${maxHeight}px` } }); From e4cb1ff9e7df5b2aa9d2f6b0f4f6d5f0ef7208e9 Mon Sep 17 00:00:00 2001 From: Jonas Date: Fri, 6 Dec 2024 13:25:16 +0100 Subject: [PATCH 3/5] Update overlays.js --- src/controls/legend/overlays.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controls/legend/overlays.js b/src/controls/legend/overlays.js index e204f0c93..575ce70f4 100644 --- a/src/controls/legend/overlays.js +++ b/src/controls/legend/overlays.js @@ -134,7 +134,7 @@ const Overlays = function Overlays(options) { // Hide overlays container when empty const onChangeLayer = function onChangeLayer() { const nrOverlays = readOverlays().length; - if(nrOverlays === 0){ + if (nrOverlays === 0) { document.getElementById(this.getId()).classList.add('hidden'); } else { document.getElementById(this.getId()).classList.remove('hidden'); From c75ca724389e4835c8de05f8a70745df7c3b76fc Mon Sep 17 00:00:00 2001 From: Jonas Date: Fri, 6 Dec 2024 13:26:13 +0100 Subject: [PATCH 4/5] Update legend.js --- src/controls/legend.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/controls/legend.js b/src/controls/legend.js index 592a3de34..06e348577 100644 --- a/src/controls/legend.js +++ b/src/controls/legend.js @@ -223,7 +223,6 @@ const Legend = function Legend(options = {}) { const setVisibleLayersViewActive = function setVisibleLayersViewActive(active) { if (!visibleLayersControl) return; visibleLayersViewActive = active; - overlaysCmp.readOverlays() if (visibleLayersViewActive) { document.getElementById(overlaysCmp.getId()).classList.add('hidden'); document.getElementById(visibleOverlaysCmp.getId()).classList.remove('hidden'); @@ -233,7 +232,7 @@ const Legend = function Legend(options = {}) { document.getElementById(toolsCmp.getId()).classList.add('hidden'); } else { const nrOverlays = overlaysCmp.readOverlays().length; - if(nrOverlays > 0){ + if(nrOverlays > 0) { document.getElementById(overlaysCmp.getId()).classList.remove('hidden'); } document.getElementById(visibleOverlaysCmp.getId()).classList.add('hidden'); From 9a049b07511d08a517582ca7c9a3f0bf3d505ecf Mon Sep 17 00:00:00 2001 From: Jonas Date: Fri, 6 Dec 2024 13:27:22 +0100 Subject: [PATCH 5/5] Update legend.js --- src/controls/legend.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controls/legend.js b/src/controls/legend.js index 06e348577..491d428c9 100644 --- a/src/controls/legend.js +++ b/src/controls/legend.js @@ -232,7 +232,7 @@ const Legend = function Legend(options = {}) { document.getElementById(toolsCmp.getId()).classList.add('hidden'); } else { const nrOverlays = overlaysCmp.readOverlays().length; - if(nrOverlays > 0) { + if (nrOverlays > 0) { document.getElementById(overlaysCmp.getId()).classList.remove('hidden'); } document.getElementById(visibleOverlaysCmp.getId()).classList.add('hidden');