more nominatim tweaks

This commit is contained in:
j 2025-08-12 12:32:34 +02:00
commit ef24247a36

View file

@ -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',