From ef24247a367448044e02e8b83f4cdfe90944e94e Mon Sep 17 00:00:00 2001 From: j Date: Tue, 12 Aug 2025 12:32:34 +0200 Subject: [PATCH] more nominatim tweaks --- source/UI/js/Map/Map.js | 43 +++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/source/UI/js/Map/Map.js b/source/UI/js/Map/Map.js index 5dc8da57..5fbb3023 100644 --- a/source/UI/js/Map/Map.js +++ b/source/UI/js/Map/Map.js @@ -884,15 +884,30 @@ Ox.Map = function(options, self) { // Use current map zoom level directly as Nominatim zoom level const currentMapZoom = Math.round(self.map.getZoom()); + // FIXME: map to nominatim zoom levels: + // https://nominatim.org/release-docs/develop/api/Reverse/ + // zoom address detail + // 3 country + // 5 state + // 8 county + // 10 city + // 12 town / borough + // 13 village / suburb + // 14 neighbourhood + // 15 any settlement + // 16 major streets + // 17 major and minor streets + // 18 building + // console.log('Reverse geocoding: using map zoom =', currentMapZoom, 'for Nominatim zoom'); - + let request = `${self.options.nominatim}/reverse?lat=${ + config.lat + }&lon=${ + config.lng + }&format=geojson&polygon_geojson=0&addressdetails=1&extratags=1&accept-language=en`; + request += `&zoom=${currentMapZoom}` + try { - const request = `${self.options.nominatim}/reverse?lat=${ - config.lat - }&lon=${ - config.lng - }&format=geojson&polygon_geojson=0&addressdetails=1&zoom=${currentMapZoom}&extratags=1`; - const response = await fetch(request); const geojson = await response.json(); @@ -911,10 +926,10 @@ Ox.Map = function(options, self) { } async function forwardGeocode(config) { const features = []; + const request = `${self.options.nominatim}/search?q=${ + config.query + }&format=geojson&polygon_geojson=0&addressdetails=1&accept-language=en`; try { - const request = `${self.options.nominatim}/search?q=${ - config.query - }&format=geojson&polygon_geojson=0&addressdetails=1`; const response = await fetch(request); const geojson = await response.json(); for (const feature of geojson.features) { @@ -1228,9 +1243,13 @@ Ox.Map = function(options, self) { 'state', 'county', 'region' ], 'city': [ - 'locality', 'city', 'town' + 'locality', 'city', 'town', 'village' + ], + 'borough': [ + 'neighborhood', 'postal_code', 'sublocality', 'suburb', 'borough' + 'neighbourhood', + ], - 'borough': ['neighborhood', 'postal_code', 'sublocality', 'suburb', 'borough'], 'street': [ 'intersection', 'route', 'street_address', 'street_number',