Skip to content

Commit

Permalink
Fix: linking images is not possible for notes or non-openstreetmap el…
Browse files Browse the repository at this point in the history
…ements
  • Loading branch information
pietervdvn committed Dec 6, 2024
1 parent 378f55b commit 7f9f7e7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
3 changes: 2 additions & 1 deletion assets/layers/note/note.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@
},
"special": {
"type": "nearby_images",
"mode": "open"
"mode": "open",
"readonly": "yes"
}
}
},
Expand Down
26 changes: 16 additions & 10 deletions src/UI/Image/NearbyImages.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
)
)
Expand All @@ -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
}
}
]
})
Expand All @@ -108,7 +108,7 @@
rotation: state.mapProperties.rotation,
pitch: state.mapProperties.pitch,
zoom: new UIEventSource<number>(16),
location: new UIEventSource({ lon, lat }),
location: new UIEventSource({ lon, lat })
})
const geocodedImageLayer = new LayerConfig(<LayerConfigJson>geocoded_image)
Expand All @@ -118,7 +118,7 @@
zoomToFeatures: true,
onClick: (feature) => {
highlighted.set(feature.properties.id)
},
}
})
ShowDataLayer.showMultipleLayers(map, new StaticFeatureSource([feature]), state.theme.layers)
Expand All @@ -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
}))
</script>

<div class="flex flex-col">
Expand Down
4 changes: 2 additions & 2 deletions src/UI/SpecialVisualizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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,
Expand Down

0 comments on commit 7f9f7e7

Please sign in to comment.