From 88f6d6e67c15c5e74484daf8ad27285a45ae19d0 Mon Sep 17 00:00:00 2001 From: Christian Beutel <> Date: Sat, 29 Mar 2025 15:31:34 +0100 Subject: [PATCH] adds toggle hotkeys to map --- .../trail/map_with_elevation_maplibre.svelte | 29 ++++++++++++++++--- .../components/trail/trail_info_panel.svelte | 16 +++++----- .../elevationprofile-control.ts | 4 +-- 3 files changed, 36 insertions(+), 13 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 916814cf..763a6407 100644 --- a/web/src/lib/components/trail/map_with_elevation_maplibre.svelte +++ b/web/src/lib/components/trail/map_with_elevation_maplibre.svelte @@ -196,7 +196,7 @@ }, } as GeoJSON); } - }); + }); return r; } @@ -909,10 +909,8 @@ trails.forEach((t, i) => { const layerId = t.id!; addTrailLayer(t, layerId, i, data[i]); - }); + }); if (activeTrail !== null) { - console.log(activeTrail); - addCaretLayer(trails[activeTrail].id!); } @@ -957,8 +955,31 @@ onDestroy(() => { map?.remove(); }); + + function handleKeydown(e: KeyboardEvent) { + if (e.key == "m") { + if (trails.length === 1) { + removeCaretLayer(); + removeTrailLayer(trails[0].id!); + } + } + } + + function handleKeyup(e: KeyboardEvent) { + if (e.key == "m") { + if (trails.length === 1) { + addTrailLayer(trails[0], trails[0].id!, 0, data[0]); + addCaretLayer(trails[0].id); + } + } else if (e.key == "p") { + if (showElevation) { + epc?.toggleProfile(); + } + } + } +