diff options
| author | user <user@node5.net> | 2024-12-28 23:45:00 +0100 |
|---|---|---|
| committer | user <user@node5.net> | 2024-12-28 23:45:00 +0100 |
| commit | 4c6a6ce7ecdb98734cc52a44dccbf90342c36933 (patch) | |
| tree | 9670dfc31cba3972c517c5e06a1c19659cc4ddcc /src | |
| parent | 70d5c873b6b6dd038d7002118c7ac266b58c048e (diff) | |
JS - Toggle layers with URL parameters
Diffstat (limited to 'src')
| -rw-r--r-- | src/static/main.js | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/static/main.js b/src/static/main.js index 3ef9cf1..102862f 100644 --- a/src/static/main.js +++ b/src/static/main.js @@ -7,9 +7,23 @@ L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { let known_store_chains; let icons = {}; -var markers = L.featureGroup().addTo(map); -var polygons = L.featureGroup().addTo(map); -var heatmap = L.featureGroup().addTo(map); +var markers = L.featureGroup() +var polygons = L.featureGroup() +var heatmap = L.featureGroup() + +const queryString = window.location.search; +const urlParams = new URLSearchParams(queryString); +if (!urlParams.has('markers') || urlParams.get('markers') == "1") { + markers.addTo(map); +} +if (!urlParams.has('polygons') || urlParams.get('polygons') == "1") { + polygons.addTo(map); +} +if (!urlParams.has('heatmap') || urlParams.get('heatmap') == "1") { + heatmap.addTo(map); +} + + const CategoryField = document.getElementById('Category'); const CountryField = document.getElementById('Country'); |
