diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2024-01-12 04:02:37 +0100 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2024-01-12 14:35:43 +0100 |
commit | 4a4750c3f6563a62fea050aa67c1f910195d1103 (patch) | |
tree | e5142efb44ffb7bacbe1b7b6aa7a4adb057c80cb /main.js | |
parent | 3194e8b8b30e0b5e17a5b5843aa04802927fd350 (diff) |
More CSS improvements and minor refactoring.
Diffstat (limited to 'main.js')
-rw-r--r-- | main.js | 24 |
1 files changed, 17 insertions, 7 deletions
@@ -134,20 +134,30 @@ const map = new Map({ source: baseMapSource }), ], - target: document.getElementById('map'), }); +map.setTarget(document.getElementById('map')); (function() { - const element = document.getElementById('layer-selection-btn'); + const menu = document.getElementById('map-menu'); + map.getViewport().append(menu); map.addControl(new Control({ - element: element, + element: menu, })); - element.onclick = function(event) { - document.getElementById('layer-selection-panel').classList.toggle('map-panel-hidden'); - element.classList.toggle('map-panel-expanded'); - }; + menu.classList.remove('d-none'); })(); +document.getElementById('layer-selection-btn').onclick = function(event) { + const btn = document.getElementById('layer-selection-btn'); + const panel = document.getElementById('layer-selection-panel'); + if (btn.ariaExpanded === 'true') { + panel.classList.add('d-none'); + btn.ariaExpanded = 'false'; + } else { + panel.classList.remove('d-none'); + btn.ariaExpanded = 'true'; + } +}; + document.getElementById('layer-topowebb_nedtonad').onchange = function(event) { const layer = event.target.checked ? 'topowebb_nedtonad' : 'topowebb'; baseMapSource.setUrl('https://minkarta.lantmateriet.se/map/topowebbcache?LAYER=' + layer); |