From e274d88c2b36dbd89829fa34b21b58687a2f4f57 Mon Sep 17 00:00:00 2001 From: j Date: Mon, 11 Aug 2025 18:47:25 +0200 Subject: [PATCH] faster lookup, start to map addresstype to type --- source/UI/js/Map/Map.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/source/UI/js/Map/Map.js b/source/UI/js/Map/Map.js index aaa74f36..9e5dc936 100644 --- a/source/UI/js/Map/Map.js +++ b/source/UI/js/Map/Map.js @@ -895,7 +895,7 @@ Ox.Map = function(options, self) { config.lat }&lon=${ config.lng - }&format=geojson&polygon_geojson=1&addressdetails=1&zoom=${currentMapZoom}&extratags=1`; + }&format=geojson&polygon_geojson=0&addressdetails=1&zoom=${currentMapZoom}&extratags=1`; const response = await fetch(request); const geojson = await response.json(); @@ -918,7 +918,7 @@ Ox.Map = function(options, self) { try { const request = `${self.options.nominatim}/search?q=${ config.query - }&format=geojson&polygon_geojson=1&addressdetails=1`; + }&format=geojson&polygon_geojson=0&addressdetails=1`; const response = await fetch(request); const geojson = await response.json(); for (const feature of geojson.features) { @@ -1185,7 +1185,7 @@ Ox.Map = function(options, self) { map: that, north: northEast.lat, south: southWest.lat, - type: getType(data.address_components[0].types), + type: getType(data.address_components[0].types, data), west: southWest.lng }; place.geoname = data.formatted_address || place.fullGeoname; @@ -1218,19 +1218,26 @@ Ox.Map = function(options, self) { ) ? name : null; }).join(', '); } - function getType(types) { + function getType(types, data) { // see https://developers.google.com/maps/documentation/javascript/geocoding#GeocodingAddressTypes + types.push(data.properties.addresstype) + var strings = { 'country': ['country'], - 'region': ['administrative_area', 'colloquial_area'], - 'city': ['locality'], - 'borough': ['neighborhood', 'postal_code', 'sublocality'], + 'region': [ + 'administrative_area', 'colloquial_area', + 'state', 'county' + ], + 'city': ['locality', 'city'], + 'borough': ['neighborhood', 'postal_code', 'sublocality', 'suburb', 'borough'], 'street': [ 'intersection', 'route', - 'street_address', 'street_number' + 'street_address', 'street_number', + 'road', ], 'building': [ - 'airport', 'floor', 'premise', 'room', 'subpremise' + 'airport', 'floor', 'premise', 'room', 'subpremise', + 'building', ], 'feature': ['natural_feature', 'park'] },