From 084cd86b71bbc26e3b7542a5f16ecc1715275a50 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Thu, 12 Sep 2024 21:42:35 +0200 Subject: [PATCH] Fix: fix move dialog --- .../NewPointLocationInput.svelte | 22 +++++++++---------- .../InputElement/Helpers/LocationInput.svelte | 8 ++++++- src/UI/Popup/MoveWizard.svelte | 1 + 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/UI/BigComponents/NewPointLocationInput.svelte b/src/UI/BigComponents/NewPointLocationInput.svelte index f677841f1..ced6c8f85 100644 --- a/src/UI/BigComponents/NewPointLocationInput.svelte +++ b/src/UI/BigComponents/NewPointLocationInput.svelte @@ -34,7 +34,12 @@ export let coordinate: { lon: number; lat: number } = undefined /** - * The center of the map at all times + * Max distance that one is allowed to move, to prevent to stray too much + */ + export let maxDistanceInMeters = 50 + + /** + * The resulting location; either the map center or the snapped coordinate * If undefined at the beginning, 'coordinate' will be used */ export let value: UIEventSource<{ lon: number; lat: number }> @@ -57,11 +62,6 @@ export let snappedTo: UIEventSource - let preciseLocation: UIEventSource<{ lon: number; lat: number }> = new UIEventSource<{ - lon: number - lat: number - }>(undefined) - const map: UIEventSource = new UIEventSource(undefined) export let mapProperties: Partial & { location } = { zoom: new UIEventSource(19), @@ -69,10 +69,7 @@ /*If no snapping needed: the value is simply the map location; * If snapping is needed: the value will be set later on by the snapping feature source * */ - location: - snapToLayers?.length > 0 - ? new UIEventSource<{ lon: number; lat: number }>(coordinate) - : value, + location: new UIEventSource<{ lon: number; lat: number }>(coordinate), bounds: new UIEventSource(undefined), allowMoving: new UIEventSource(true), allowZooming: new UIEventSource(true), @@ -143,15 +140,16 @@ }) withCorrectedAttributes.features.addCallbackAndRunD((f) => console.log("Snapped point is", f)) } + 0 ? new UIEventSource(undefined) : value} initialCoordinate={coordinate} - maxDistanceInMeters={50} + {maxDistanceInMeters} > diff --git a/src/UI/InputElement/Helpers/LocationInput.svelte b/src/UI/InputElement/Helpers/LocationInput.svelte index 854f1c01c..148fd8f12 100644 --- a/src/UI/InputElement/Helpers/LocationInput.svelte +++ b/src/UI/InputElement/Helpers/LocationInput.svelte @@ -18,9 +18,15 @@ /** * A visualisation to pick a location on a map background */ + /** + * The center of the map. If it contains a value (and initialCoordinate is not given), this will be used as start coordinate + */ export let value: UIEventSource<{ lon: number; lat: number }> - export let initialCoordinate: { lon: number; lat: number } + export let initialCoordinate: { lon: number; lat: number } = undefined initialCoordinate = initialCoordinate ?? value.data + /** + * Max distance that one is allowed to stray from the initial coordinate + */ export let maxDistanceInMeters: number = undefined export let mapProperties: Partial & { readonly location: UIEventSource<{ lon: number; lat: number }> diff --git a/src/UI/Popup/MoveWizard.svelte b/src/UI/Popup/MoveWizard.svelte index 604bbf3dc..12cb921de 100644 --- a/src/UI/Popup/MoveWizard.svelte +++ b/src/UI/Popup/MoveWizard.svelte @@ -106,6 +106,7 @@ snapToLayers={$reason.snapTo} targetLayer={layer} dontShow={[id]} + maxDistanceInMeters={200} />