From 72d6701a512f96acf4ebffc61a4870ae9c9fea7a Mon Sep 17 00:00:00 2001 From: Christian Beutel <> Date: Thu, 16 Jan 2025 00:32:53 +0100 Subject: [PATCH] adds geolocation to map --- .../trail/map_with_elevation_maplibre.svelte | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 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 ceb8b57b..a31455c6 100644 --- a/web/src/lib/components/trail/map_with_elevation_maplibre.svelte +++ b/web/src/lib/components/trail/map_with_elevation_maplibre.svelte @@ -461,7 +461,7 @@ ) { if (showElevationMarker) { elevationMarker.setOpacity("1"); - } + } map?.setPaintProperty(id, "line-width", 7); hoveringTrail = true; // map?.setPaintProperty(id, "line-color", "#2766e3"); @@ -567,7 +567,7 @@ const startEndPoint = findStartAndEndPoints(geojson); - if(!startEndPoint.length) { + if (!startEndPoint.length) { return; } @@ -735,6 +735,22 @@ "top-left", ); + map.addControl( + new M.GeolocateControl({ + positionOptions: { + enableHighAccuracy: true, + }, + fitBoundsOptions: { + animate: fitBounds == "animate" + }, + trackUserLocation: true, + }), + ); + + if (showStyleSwitcher) { + map.addControl(switcherControl); + } + if (showElevation) { epc = new ElevationProfileControl({ visible: false, @@ -755,7 +771,7 @@ onLeave: () => { elevationMarker.setOpacity("0"); }, - onMove: (data) => { + onMove: (data) => { if (!hoveringTrail) { elevationMarker.setLngLat( data.position as M.LngLatLike, @@ -765,9 +781,6 @@ }); map.addControl(epc); } - if (showStyleSwitcher) { - map.addControl(switcherControl); - } if (showFullscreen) { map.addControl(