Create new places

And find them in search
This commit is contained in:
2026-01-27 11:58:24 +07:00
parent a10f87290a
commit 8c58a76030
12 changed files with 507 additions and 58 deletions

30
app/routes/place/new.js Normal file
View File

@@ -0,0 +1,30 @@
import Route from '@ember/routing/route';
import { service } from '@ember/service';
export default class PlaceNewRoute extends Route {
@service mapUi;
queryParams = {
lat: { refreshModel: true },
lon: { refreshModel: true },
};
model(params) {
return {
lat: parseFloat(params.lat),
lon: parseFloat(params.lon),
};
}
setupController(controller, model) {
super.setupController(controller, model);
if (model.lat && model.lon) {
this.mapUi.updateCreationCoordinates(model.lat, model.lon);
}
this.mapUi.startCreating();
}
deactivate() {
this.mapUi.stopCreating();
}
}

View File

@@ -28,6 +28,26 @@ export default class SearchRoute extends Route {
// Fetch POIs
let pois = await this.osm.getNearbyPois(lat, lon, searchRadius);
// Get cached/saved places in search radius
const localMatches = this.storage.savedPlaces.filter((p) => {
const dist = getDistance(lat, lon, p.lat, p.lon);
return dist <= searchRadius;
});
// Add local matches to the list if they aren't already there
// We use osmId to deduplicate if possible
localMatches.forEach((local) => {
const exists = pois.find(
(poi) =>
(local.osmId && poi.osmId === local.osmId) ||
(poi.id && poi.id === local.id)
);
if (!exists) {
pois.push(local);
}
});
// Sort by distance from click
pois = pois
.map((p) => {