From 2c7a29b2f4bc57f2913ef234b2ac07e7bb8cbfea Mon Sep 17 00:00:00 2001 From: Zack Pollard Date: Thu, 19 Jun 2025 12:05:40 +0100 Subject: [PATCH] fix: panning interrupted while moving around the map --- .../lib/components/shared-components/map/map.svelte | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/web/src/lib/components/shared-components/map/map.svelte b/web/src/lib/components/shared-components/map/map.svelte index af9604b680..deb081159e 100644 --- a/web/src/lib/components/shared-components/map/map.svelte +++ b/web/src/lib/components/shared-components/map/map.svelte @@ -22,7 +22,7 @@ import { isEqual, omit } from 'lodash-es'; import { DateTime, Duration } from 'luxon'; import maplibregl, { GlobeControl, type GeoJSONSource, type LngLatLike } from 'maplibre-gl'; - import { onDestroy, onMount } from 'svelte'; + import { onDestroy, onMount, untrack } from 'svelte'; import { t } from 'svelte-i18n'; import { AttributionControl, @@ -61,7 +61,7 @@ mapMarkers = $bindable(), showSettings = true, zoom = undefined, - center = $bindable(undefined), + center = undefined, hash = false, simplified = false, clickable = false, @@ -250,8 +250,14 @@ }); }); + let lastCenter: LngLatLike | undefined = undefined; + $effect(() => { + if (!map || !center || isEqual(lastCenter, center)) { + return; + } map?.jumpTo({ center, zoom }); + lastCenter = center; });