From 722fb24ab2cf606a60b34991bb4e6f36b7e8ec18 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Thu, 5 Jun 2025 15:18:05 +0200 Subject: Update default view. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use Lantmäteriet's 'topowebb_nedtonad' basemap, and show some layers. This is more or less what's being linked to at https://www.klimatanalysnorr.se/kartor-2/ . For existing links to the old non-hierarchical names, we simply use the default view instead of trying to map layer names to the new ones. --- example.html | 2 +- main.js | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/example.html b/example.html index 5dd0e01..67e8300 100644 --- a/example.html +++ b/example.html @@ -15,7 +15,7 @@ man välja lager, ladda ner kartan som PNG-fil, och få information om de olika föremålen.

- + diff --git a/main.js b/main.js index 4c424db..d857899 100644 --- a/main.js +++ b/main.js @@ -119,7 +119,7 @@ const view = new View({ constrainResolution: false, }); -let baseMapLayer = 'topowebb'; +let baseMapLayer = 'topowebb_nedtonad'; (function() { const params = new URLSearchParams(window.location.hash.substring(1)); const x = parseFloat(params.get('x')); @@ -131,6 +131,33 @@ let baseMapLayer = 'topowebb'; if (!isNaN(z)) { view.setZoom(z); } + if (params.has('layers')) { + const layers = params.get('layers').split(' '); + if (layers.length > 0 && !layers.some((l) => l.includes('.'))) { + /* compat redirect/layer subst for old non-hierachical names */ + params.delete('layers'); + } + } + if (!params.has('layers')) { + params.set('layers', [ + 'svk.ledningar', + 'svk.stolpar', + 'svk.stationer', + 'svk.transmissionsnatsprojekt', + 'misc.gigafactories', + 'misc.dammar', + 'mrr.appr_ec', + 'mrr.appl_ec', + 'mrr.appr_ogd', + 'mrr.appl_ogd', + 'mrr.appr_met', + 'mrr.appl_met', + 'mrr.appr_dl', + 'vbk.area_current', + 'vbk.area_notcurrent', + ].join(' ')); + location.hash = '#' + params.toString(); + } if (params.has('basemap')) { baseMapLayer = params.get('basemap'); -- cgit v1.2.3