Hide search result markers when result is selected

This commit is contained in:
2026-03-28 15:30:27 +04:00
parent 2b219fe0cf
commit dc9e0f210a

View File

@@ -119,6 +119,28 @@ export default class MapComponent extends Component {
const searchResultStyle = (feature) => { const searchResultStyle = (feature) => {
const originalPlace = feature.get('originalPlace'); 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 // Some search results might be just the place object without separate tags
// If it's a raw place object, it might have osmTags property. // If it's a raw place object, it might have osmTags property.
// Or it might be the tags object itself. // Or it might be the tags object itself.
@@ -599,6 +621,11 @@ export default class MapComponent extends Component {
const selected = this.mapUi.selectedPlace; const selected = this.mapUi.selectedPlace;
const options = this.mapUi.selectionOptions || {}; 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; if (!this.selectedPinOverlay || !this.selectedPinElement) return;
// Clear any previous shape // Clear any previous shape