From dc9e0f210a5307439eb607dd74e4aea96c07b419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Sat, 28 Mar 2026 15:30:27 +0400 Subject: [PATCH] Hide search result markers when result is selected --- app/components/map.gjs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/app/components/map.gjs b/app/components/map.gjs index 3d0e8f8..2ec439a 100644 --- a/app/components/map.gjs +++ b/app/components/map.gjs @@ -119,6 +119,28 @@ export default class MapComponent extends Component { const searchResultStyle = (feature) => { const originalPlace = feature.get('originalPlace'); + + // If this place is currently selected, hide the search result marker + // because the main red drop pin will be shown instead. + const selectedPlace = this.mapUi.selectedPlace; + if (selectedPlace) { + const isSameOsmId = + originalPlace.osmId && + selectedPlace.osmId && + originalPlace.osmId === selectedPlace.osmId; + const isSameId = + originalPlace.id && + selectedPlace.id && + originalPlace.id === selectedPlace.id; + const isSameCoords = + originalPlace.lat === selectedPlace.lat && + originalPlace.lon === selectedPlace.lon; + + if (isSameOsmId || isSameId || isSameCoords) { + return new Style({}); // Empty style makes it invisible + } + } + // Some search results might be just the place object without separate tags // If it's a raw place object, it might have osmTags property. // Or it might be the tags object itself. @@ -599,6 +621,11 @@ export default class MapComponent extends Component { const selected = this.mapUi.selectedPlace; const options = this.mapUi.selectionOptions || {}; + // Force a redraw of the search results layer so it can hide/show the selected pin + if (this.searchResultsSource) { + this.searchResultsSource.changed(); + } + if (!this.selectedPinOverlay || !this.selectedPinElement) return; // Clear any previous shape