Files
marco/app/services/map-ui.js
Râu Cao 818ec35071 Ensure map marker clicks preserve search context
Fixes the back button just closing the sidebar and clearing the whole
search after having seleted a result via map marker
2026-03-23 16:42:32 +04:00

74 lines
1.5 KiB
JavaScript

import Service from '@ember/service';
import { tracked } from '@glimmer/tracking';
export default class MapUiService extends Service {
@tracked selectedPlace = null;
@tracked isSearching = false;
@tracked isCreating = false;
@tracked creationCoordinates = null;
@tracked returnToSearch = false;
@tracked currentCenter = null;
@tracked currentBounds = null;
@tracked searchBoxHasFocus = false;
@tracked selectionOptions = {};
@tracked preventNextZoom = false;
@tracked searchResults = [];
@tracked currentSearch = null;
selectPlace(place, options = {}) {
this.selectedPlace = place;
this.selectionOptions = options;
}
clearSelection() {
this.selectedPlace = null;
this.selectionOptions = {};
this.preventNextZoom = false;
}
setSearchResults(results) {
this.searchResults = results || [];
}
clearSearchResults() {
this.searchResults = [];
this.currentSearch = null;
}
startSearch() {
this.isSearching = true;
this.isCreating = false;
this.preventNextZoom = false;
}
stopSearch() {
this.isSearching = false;
}
startCreating() {
this.isCreating = true;
this.isSearching = false;
}
stopCreating() {
this.isCreating = false;
this.creationCoordinates = null;
}
updateCreationCoordinates(lat, lon) {
this.creationCoordinates = { lat, lon };
}
setSearchBoxFocus(isFocused) {
this.searchBoxHasFocus = isFocused;
}
updateCenter(lat, lon) {
this.currentCenter = { lat, lon };
}
updateBounds(bounds) {
this.currentBounds = bounds;
}
}