fix: panning interrupted while moving around the map
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
import { isEqual, omit } from 'lodash-es';
|
import { isEqual, omit } from 'lodash-es';
|
||||||
import { DateTime, Duration } from 'luxon';
|
import { DateTime, Duration } from 'luxon';
|
||||||
import maplibregl, { GlobeControl, type GeoJSONSource, type LngLatLike } from 'maplibre-gl';
|
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 { t } from 'svelte-i18n';
|
||||||
import {
|
import {
|
||||||
AttributionControl,
|
AttributionControl,
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
mapMarkers = $bindable(),
|
mapMarkers = $bindable(),
|
||||||
showSettings = true,
|
showSettings = true,
|
||||||
zoom = undefined,
|
zoom = undefined,
|
||||||
center = $bindable(undefined),
|
center = undefined,
|
||||||
hash = false,
|
hash = false,
|
||||||
simplified = false,
|
simplified = false,
|
||||||
clickable = false,
|
clickable = false,
|
||||||
@@ -250,8 +250,14 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let lastCenter: LngLatLike | undefined = undefined;
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
|
if (!map || !center || isEqual(lastCenter, center)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
map?.jumpTo({ center, zoom });
|
map?.jumpTo({ center, zoom });
|
||||||
|
lastCenter = center;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user