Show map pin for currently selected place
This commit is contained in:
@@ -4,6 +4,7 @@ import { service } from '@ember/service';
|
||||
export default class PlaceRoute extends Route {
|
||||
@service storage;
|
||||
@service osm;
|
||||
@service mapUi;
|
||||
|
||||
async model(params) {
|
||||
const id = params.place_id;
|
||||
@@ -16,15 +17,8 @@ export default class PlaceRoute extends Route {
|
||||
}
|
||||
|
||||
// 1. Try to find in local bookmarks
|
||||
// We rely on the service maintaining the list
|
||||
let bookmark = this.storage.findPlaceById(id);
|
||||
|
||||
// If not found instantly, maybe wait for storage ready?
|
||||
// For now assuming storage is reasonably fast or "ready" has fired.
|
||||
// If we land here directly on refresh, "savedPlaces" might be empty initially.
|
||||
// We could retry or wait, but simpler to fall back to OSM for now.
|
||||
// Ideally, we await `storage.loadAllPlaces()` promise if it's pending.
|
||||
|
||||
if (bookmark) {
|
||||
console.log('Found in bookmarks:', bookmark.title);
|
||||
return bookmark;
|
||||
@@ -35,6 +29,18 @@ export default class PlaceRoute extends Route {
|
||||
return this.loadOsmPlace(id);
|
||||
}
|
||||
|
||||
afterModel(model) {
|
||||
// Notify the Map UI to show the pin
|
||||
if (model) {
|
||||
this.mapUi.selectPlace(model);
|
||||
}
|
||||
}
|
||||
|
||||
deactivate() {
|
||||
// Clear the pin when leaving the route
|
||||
this.mapUi.clearSelection();
|
||||
}
|
||||
|
||||
async loadOsmPlace(id, type = null) {
|
||||
try {
|
||||
const poi = await this.osm.getPoiById(id, type);
|
||||
|
||||
Reference in New Issue
Block a user