diff --git a/umap/static/umap/js/modules/data/layer.js b/umap/static/umap/js/modules/data/layer.js index 92808cc2..61e2dc8a 100644 --- a/umap/static/umap/js/modules/data/layer.js +++ b/umap/static/umap/js/modules/data/layer.js @@ -966,11 +966,11 @@ export class DataLayer extends ServerStored { this.propagateHide() } - toggle() { + toggle(status) { // From now on, do not try to how/hidedataChanged // automatically this layer. this._forcedVisibility = true - if (!this.isVisible()) this.show() + if (!this.isVisible() || status) this.show() else this.hide() } @@ -1258,7 +1258,7 @@ export class DataLayer extends ServerStored { this ) } - DomEvent.on(toggle, 'click', this.toggle, this) + DomEvent.on(toggle, 'click', () => this.toggle()) DomEvent.on(zoomTo, 'click', this.zoomTo, this) container.classList.add(this.getHidableClass()) container.classList.toggle('off', !this.isVisible()) diff --git a/umap/static/umap/js/modules/ui/bar.js b/umap/static/umap/js/modules/ui/bar.js index 32f64e0c..146ec3b3 100644 --- a/umap/static/umap/js/modules/ui/bar.js +++ b/umap/static/umap/js/modules/ui/bar.js @@ -194,11 +194,7 @@ export class BottomBar extends WithTemplate { const select = this.elements.layers const selected = select.options[select.selectedIndex].value this._umap.eachDataLayer((datalayer) => { - if (datalayer.id === selected) { - datalayer.show() - } else { - datalayer.hide() - } + datalayer.toggle(datalayer.id === selected) }) }) this.redraw()