From 95377f03c35826cab31b37e8b27147be16fae008 Mon Sep 17 00:00:00 2001 From: Christian Beutel <> Date: Thu, 10 Jul 2025 13:45:07 +0200 Subject: [PATCH] fixes hidden trail after map style switch --- .../trail/map_with_elevation_maplibre.svelte | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/web/src/lib/components/trail/map_with_elevation_maplibre.svelte b/web/src/lib/components/trail/map_with_elevation_maplibre.svelte index b6721326..5c33c90a 100644 --- a/web/src/lib/components/trail/map_with_elevation_maplibre.svelte +++ b/web/src/lib/components/trail/map_with_elevation_maplibre.svelte @@ -116,8 +116,6 @@ let hoveringTrail: boolean = false; - let loadedAfterStyleSwitch = false; - const trailColors = [ "#3549BB", "#592E9E", @@ -938,7 +936,6 @@ layers = {}; map?.setStyle(style.value); localStorage.setItem("layer", style.text); - loadedAfterStyleSwitch = true; }, selectedIndex: preferredMapStyleIndex !== -1 ? preferredMapStyleIndex : 0, @@ -1046,16 +1043,19 @@ }); } - if (loadedAfterStyleSwitch) { - trails.forEach((t, i) => { - const layerId = t.id!; - addTrailLayer(t, layerId, i, data[i]); - }); - if (activeTrail !== null) { - addCaretLayer(trails[activeTrail].id!); - } + trails.forEach((t, i) => { + const layerId = t.id!; - loadedAfterStyleSwitch = false; + if (map?.getLayer(layerId)) { + return; + } + addTrailLayer(t, layerId, i, data[i]); + }); + if ( + activeTrail !== null && + !map?.getLayer("direction-carets") + ) { + addCaretLayer(trails[activeTrail].id!); } } catch (e) {} }