From 7f9f7e753443e779b16a544bc6312214ae26dab4 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Fri, 6 Dec 2024 01:07:30 +0100 Subject: [PATCH] Fix: linking images is not possible for notes or non-openstreetmap elements --- assets/layers/note/note.json | 3 ++- src/UI/Image/NearbyImages.svelte | 26 ++++++++++++++++---------- src/UI/SpecialVisualizations.ts | 4 ++-- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/assets/layers/note/note.json b/assets/layers/note/note.json index 271336a11..8d480fa1a 100644 --- a/assets/layers/note/note.json +++ b/assets/layers/note/note.json @@ -132,7 +132,8 @@ }, "special": { "type": "nearby_images", - "mode": "open" + "mode": "open", + "readonly": "yes" } } }, diff --git a/src/UI/Image/NearbyImages.svelte b/src/UI/Image/NearbyImages.svelte index 8f2022c93..153f2e483 100644 --- a/src/UI/Image/NearbyImages.svelte +++ b/src/UI/Image/NearbyImages.svelte @@ -59,12 +59,12 @@ type: "Feature", geometry: { type: "Point", - coordinates: [p4c.coordinates.lng, p4c.coordinates.lat], + coordinates: [p4c.coordinates.lng, p4c.coordinates.lat] }, properties: { id: p4c.pictureUrl, - rotation: p4c.direction, - }, + rotation: p4c.direction + } } ) ) @@ -76,14 +76,14 @@ type: "Feature", geometry: { type: "Point", - coordinates: [s.coordinates.lng, s.coordinates.lat], + coordinates: [s.coordinates.lng, s.coordinates.lat] }, properties: { id: s.pictureUrl, selected: "yes", - rotation: s.direction, - }, - }, + rotation: s.direction + } + } ] }) @@ -108,7 +108,7 @@ rotation: state.mapProperties.rotation, pitch: state.mapProperties.pitch, zoom: new UIEventSource(16), - location: new UIEventSource({ lon, lat }), + location: new UIEventSource({ lon, lat }) }) const geocodedImageLayer = new LayerConfig(geocoded_image) @@ -118,7 +118,7 @@ zoomToFeatures: true, onClick: (feature) => { highlighted.set(feature.properties.id) - }, + } }) ShowDataLayer.showMultipleLayers(map, new StaticFeatureSource([feature]), state.theme.layers) @@ -141,8 +141,14 @@ layer: geocodedImageLayer, onClick: (feature) => { highlighted.set(feature.properties.id) - }, + } }) + onDestroy(tags.addCallbackAndRunD(tags => { + if (tags.id.startsWith("node/") || tags.id.startsWith("way/") || tags.id.startsWith("relation/")) { + return + } + linkable = false + }))
diff --git a/src/UI/SpecialVisualizations.ts b/src/UI/SpecialVisualizations.ts index 92979445e..ac492a00f 100644 --- a/src/UI/SpecialVisualizations.ts +++ b/src/UI/SpecialVisualizations.ts @@ -112,7 +112,7 @@ class NearbyImageVis implements SpecialVisualization { { name: "readonly", required: false, - doc: "If 'readonly', will not show the 'link'-button", + doc: "If 'readonly' or 'yes', will not show the 'link'-button", }, ] docs = @@ -128,7 +128,7 @@ class NearbyImageVis implements SpecialVisualization { layer: LayerConfig ): SvelteUIElement { const isOpen = args[0] === "open" - const readonly = args[1] === "readonly" + const readonly = args[1] === "readonly" || args[1] === "yes" const [lon, lat] = GeoOperations.centerpointCoordinates(feature) return new SvelteUIElement(isOpen ? NearbyImages : NearbyImagesCollapsed, { tags,