Fix: linking images is not possible for notes or non-openstreetmap elements

This commit is contained in:
Pieter Vander Vennet 2024-12-06 01:07:30 +01:00
parent 378f55b544
commit 7f9f7e7534
3 changed files with 20 additions and 13 deletions

View file

@ -132,7 +132,8 @@
}, },
"special": { "special": {
"type": "nearby_images", "type": "nearby_images",
"mode": "open" "mode": "open",
"readonly": "yes"
} }
} }
}, },

View file

@ -59,12 +59,12 @@
type: "Feature", type: "Feature",
geometry: { geometry: {
type: "Point", type: "Point",
coordinates: [p4c.coordinates.lng, p4c.coordinates.lat], coordinates: [p4c.coordinates.lng, p4c.coordinates.lat]
}, },
properties: { properties: {
id: p4c.pictureUrl, id: p4c.pictureUrl,
rotation: p4c.direction, rotation: p4c.direction
}, }
} }
) )
) )
@ -76,14 +76,14 @@
type: "Feature", type: "Feature",
geometry: { geometry: {
type: "Point", type: "Point",
coordinates: [s.coordinates.lng, s.coordinates.lat], coordinates: [s.coordinates.lng, s.coordinates.lat]
}, },
properties: { properties: {
id: s.pictureUrl, id: s.pictureUrl,
selected: "yes", selected: "yes",
rotation: s.direction, rotation: s.direction
}, }
}, }
] ]
}) })
@ -108,7 +108,7 @@
rotation: state.mapProperties.rotation, rotation: state.mapProperties.rotation,
pitch: state.mapProperties.pitch, pitch: state.mapProperties.pitch,
zoom: new UIEventSource<number>(16), zoom: new UIEventSource<number>(16),
location: new UIEventSource({ lon, lat }), location: new UIEventSource({ lon, lat })
}) })
const geocodedImageLayer = new LayerConfig(<LayerConfigJson>geocoded_image) const geocodedImageLayer = new LayerConfig(<LayerConfigJson>geocoded_image)
@ -118,7 +118,7 @@
zoomToFeatures: true, zoomToFeatures: true,
onClick: (feature) => { onClick: (feature) => {
highlighted.set(feature.properties.id) highlighted.set(feature.properties.id)
}, }
}) })
ShowDataLayer.showMultipleLayers(map, new StaticFeatureSource([feature]), state.theme.layers) ShowDataLayer.showMultipleLayers(map, new StaticFeatureSource([feature]), state.theme.layers)
@ -141,8 +141,14 @@
layer: geocodedImageLayer, layer: geocodedImageLayer,
onClick: (feature) => { onClick: (feature) => {
highlighted.set(feature.properties.id) 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
}))
</script> </script>
<div class="flex flex-col"> <div class="flex flex-col">

View file

@ -112,7 +112,7 @@ class NearbyImageVis implements SpecialVisualization {
{ {
name: "readonly", name: "readonly",
required: false, required: false,
doc: "If 'readonly', will not show the 'link'-button", doc: "If 'readonly' or 'yes', will not show the 'link'-button",
}, },
] ]
docs = docs =
@ -128,7 +128,7 @@ class NearbyImageVis implements SpecialVisualization {
layer: LayerConfig layer: LayerConfig
): SvelteUIElement { ): SvelteUIElement {
const isOpen = args[0] === "open" const isOpen = args[0] === "open"
const readonly = args[1] === "readonly" const readonly = args[1] === "readonly" || args[1] === "yes"
const [lon, lat] = GeoOperations.centerpointCoordinates(feature) const [lon, lat] = GeoOperations.centerpointCoordinates(feature)
return new SvelteUIElement(isOpen ? NearbyImages : NearbyImagesCollapsed, { return new SvelteUIElement(isOpen ? NearbyImages : NearbyImagesCollapsed, {
tags, tags,