fix(maps): nominatim autocomplete and search fallback keep the location bias

On an install without the TREK Places index and without a Google key the
suggestions come from Nominatim, and autocompleteNominatim asked it without
the box the client had sent, so every suggestion was ranked globally. The
search fallback on the same install dropped the bias the same way. Both now
pass it on as a viewbox with bounded=0, which ranks results near the trip
without hiding anything further away.

Refs #2620
This commit is contained in:
Maurice
2026-10-12 12:41:55 +02:00
parent 5afdbc8633
commit cec5ff1e2e
3 changed files with 50 additions and 3 deletions
+2 -2
View File
@@ -393,7 +393,7 @@ export class MapsService {
// first call carried a viewbox with bounded=0, which orders results
// without changing which ones exist, so a second call can only return the
// same empty list a throttle-interval later.
const places = osmAnswer ?? (await this.osm.searchNominatim(query, lang));
const places = osmAnswer ?? (await this.osm.searchNominatim(query, lang, 'interactive', locationBias));
return { places, source: 'openstreetmap' };
}
@@ -532,7 +532,7 @@ export class MapsService {
}
if (!apiKey) {
return this.osm.autocompleteNominatim(input, lang);
return this.osm.autocompleteNominatim(input, lang, boxCentre);
}
const google = this.googlePlaces.provider({ key: apiKey, source: keySource, userId });
+2 -1
View File
@@ -267,9 +267,10 @@ export class OsmClient {
async autocompleteNominatim(
input: string,
lang?: string,
bias?: { lat: number; lng: number },
): Promise<{ suggestions: { placeId: string; mainText: string; secondaryText: string }[]; source: 'nominatim' }> {
try {
const places = await this.searchNominatim(input, lang);
const places = await this.searchNominatim(input, lang, 'interactive', bias);
const suggestions = places
.filter((p) => p.osm_id && p.osm_id.includes(':') && p.osm_id.split(':')[1] !== '')
.slice(0, 5)