diff --git a/css/style.css b/css/style.css index c020eea..707dd12 100644 --- a/css/style.css +++ b/css/style.css @@ -64,4 +64,10 @@ canvas { #map-selector-maps > button { width: 100%; +} + +#map-selector-maps > button[disabled] { + color: #bbb; + /* based on ol.css button styling */ + background-color: rgba(0, 30, 68, 0.75); } \ No newline at end of file diff --git a/js/MapSelector.js b/js/MapSelector.js index 81f9091..66050b4 100644 --- a/js/MapSelector.js +++ b/js/MapSelector.js @@ -41,14 +41,14 @@ class MapSelector extends Control { this.maps = list.maps; this.updateList(); - + }); } handleMapChange(selected) { const map = this.getMap(); MapLoader.loadLayers(map, selected.id).then(() => this.mapChangeCallback(selected, map)); - + this.selected = selected; this.updateList(); } @@ -58,12 +58,14 @@ class MapSelector extends Control { this.selectedLabel.innerHTML = this.selected.name; for (const map of this.maps) { - if (this.selected.id === map.id) - continue; const mapButton = document.createElement('button'); mapButton.innerHTML = map.name; - mapButton.addEventListener('click', this.handleMapChange.bind(this, map), false); + + if (this.selected.id === map.id) + mapButton.setAttribute("disabled", "") + else + mapButton.addEventListener('click', this.handleMapChange.bind(this, map), false); this.listElement.appendChild(mapButton); }