Search: load the popup of the OSM-object when clicked on the map, also when zoomed out

This commit is contained in:
Pieter Vander Vennet 2024-10-11 00:15:56 +02:00
parent a9d6aaa448
commit 48dc03b1e6
2 changed files with 34 additions and 7 deletions

View file

@ -135,12 +135,21 @@ export default class SearchState {
}
}
clickedOnMap(feature: Feature) {
async clickedOnMap(feature: Feature) {
const osmid = feature.properties.osm_id
const localElement = this.state.indexedFeatures.featuresById.data.get(osmid)
if (localElement) {
this.state.selectedElement.set(localElement)
return
}
// This feature might not be loaded because we zoomed out
const object = await this.state.osmObjectDownloader.DownloadObjectAsync(osmid)
if(object === "deleted"){
return
}
const f = object.asGeoJson()
this.state.indexedFeatures.addItem(f)
this.state.featureProperties.trackFeature(f)
this.state.selectedElement.set(f)
}
}