From aa89d4120c052b848fd5bee8077246bb4bb032bf Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Wed, 31 Jan 2024 11:37:09 +0100 Subject: [PATCH] Merge upstream --- .../Sources/SnappingFeatureSource.ts | 5 ++- .../NewPointLocationInput.svelte | 40 ++++++++----------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/Logic/FeatureSource/Sources/SnappingFeatureSource.ts b/src/Logic/FeatureSource/Sources/SnappingFeatureSource.ts index 6cc85858f..78cd3e3d7 100644 --- a/src/Logic/FeatureSource/Sources/SnappingFeatureSource.ts +++ b/src/Logic/FeatureSource/Sources/SnappingFeatureSource.ts @@ -6,11 +6,14 @@ import { BBox } from "../../BBox" export interface SnappingOptions { /** - * If the distance is bigger then this amount, don't snap. + * If the distance to the line is bigger then this amount, don't snap. * In meter */ maxDistance: number + /** + * If set to true, no value will be given if no snapping was made + */ allowUnsnapped?: false | boolean /** diff --git a/src/UI/BigComponents/NewPointLocationInput.svelte b/src/UI/BigComponents/NewPointLocationInput.svelte index bf17a273a..d5c536d9b 100644 --- a/src/UI/BigComponents/NewPointLocationInput.svelte +++ b/src/UI/BigComponents/NewPointLocationInput.svelte @@ -7,7 +7,10 @@ import { BBox } from "../../Logic/BBox" import type { MapProperties } from "../../Models/MapProperties" import ShowDataLayer from "../Map/ShowDataLayer" - import type { FeatureSource, FeatureSourceForLayer } from "../../Logic/FeatureSource/FeatureSource" + import type { + FeatureSource, + FeatureSourceForLayer, + } from "../../Logic/FeatureSource/FeatureSource" import SnappingFeatureSource from "../../Logic/FeatureSource/Sources/SnappingFeatureSource" import FeatureSourceMerger from "../../Logic/FeatureSource/Sources/FeatureSourceMerger" import LayerConfig from "../../Models/ThemeConfig/LayerConfig" @@ -40,14 +43,7 @@ coordinate = value.data } export let snapToLayers: string[] | undefined - export let targetLayer: LayerConfig | LayerConfig[] | undefined - - let targetLayers: LayerConfig[] | undefined - if (Array.isArray(targetLayers)) { - targetLayers = targetLayer - } else if (targetLayer) { - targetLayers = [targetLayer] - } + export let targetLayer: LayerConfig | undefined export let maxSnapDistance: number = undefined export let snappedTo: UIEventSource @@ -61,7 +57,7 @@ const xyz = Tiles.embedded_tile(coordinate.lat, coordinate.lon, 16) const map: UIEventSource = new UIEventSource(undefined) - let initialMapProperties: Partial = { + let initialMapProperties: Partial & {location} = { zoom: new UIEventSource(19), maxbounds: new UIEventSource(undefined), /*If no snapping needed: the value is simply the map location; @@ -78,15 +74,15 @@ rasterLayer: UIEventSource.feedFrom(state.mapProperties.rasterLayer), } - targetLayers?.forEach(layer => { - const featuresForLayer = state.perLayer.get(layer.id) + if (targetLayer) { + const featuresForLayer = state.perLayer.get(targetLayer.id) if (featuresForLayer) { new ShowDataLayer(map, { - layer, + layer: targetLayer, features: featuresForLayer, }) } - }) + } if (snapToLayers?.length > 0) { const snapSources: FeatureSource[] = [] @@ -111,25 +107,23 @@ allowUnsnapped: true, snappedTo, snapLocation: value, - }, + } ) - targetLayers.forEach(layer => { - new ShowDataLayer(map, { - layer, - features: snappedLocation, - }) + new ShowDataLayer(map, { + layer: targetLayer, + features: snappedLocation, }) } dispatch("click", data)} + mapProperties={initialMapProperties} value={preciseLocation} + initialCoordinate={coordinate} + maxDistanceInMeters={50} >