aboutsummaryrefslogtreecommitdiffstats
path: root/main.js
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2024-01-18 12:52:25 +0100
committerGuilhem Moulin <guilhem@fripost.org>2024-01-18 12:52:34 +0100
commitf530d659e5285a163d6874e9a4da15f74bae4219 (patch)
tree2565afbd283cdf57b6c83b82ebd306d9cf39f1d6 /main.js
parentf8c46e24a2e12003cd2bec7fea1dbc51e4ee5109 (diff)
Populate #layer-selection-panel in JS.
Diffstat (limited to 'main.js')
-rw-r--r--main.js46
1 files changed, 41 insertions, 5 deletions
diff --git a/main.js b/main.js
index 52e9ecc..9348bbe 100644
--- a/main.js
+++ b/main.js
@@ -361,11 +361,6 @@ const menu = document.getElementById('map-menu');
/* we're all set, show the control container now */
container.setAttribute('aria-hidden', 'false');
-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);
-};
-
const TRAILING_ZEROES = /\.?0*$/;
map.on('singleclick', function(event) {
const size = map.getSize();
@@ -389,3 +384,44 @@ view.on('change', function(event) {
searchParams.set('z', view.getZoom().toFixed(3).replace(TRAILING_ZEROES, ''));
location.hash = '#' + searchParams.toString();
});
+
+
+/* layer selection panel */
+(function() {
+ const modal = document.getElementById('layer-selection-panel');
+ modal.classList.add('modal');
+ modal.setAttribute('role', 'dialog');
+ modal.setAttribute('aria-hidden', 'true');
+
+ const content = document.createElement('div');
+ modal.appendChild(content);
+ content.classList.add('modal-content');
+
+ const body = document.createElement('div');
+ content.appendChild(body);
+ body.classList.add('modal-body');
+
+ (function() {
+ const div = document.createElement('div');
+ body.appendChild(div);
+ div.classList.add('form-check', 'form-switch');
+
+ const input = document.createElement('input');
+ div.appendChild(input);
+ input.classList.add('form-check-input');
+ input.type = 'checkbox';
+ input.setAttribute('role', 'switch');
+ input.id = 'layer-basemap';
+
+ const label = document.createElement('label');
+ div.appendChild(label);
+ label.classList.add('form-check-label');
+ label.setAttribute('for', input.id);
+ label.innerHTML = 'Nedtonad bakgrund karta';
+
+ input.onchange = function(event) {
+ const layer = event.target.checked ? 'topowebb_nedtonad' : 'topowebb';
+ baseMapSource.setUrl('https://minkarta.lantmateriet.se/map/topowebbcache?LAYER=' + layer);
+ };
+ })();
+})();