more nominatim tweaks
This commit is contained in:
parent
529277eb12
commit
ef24247a36
1 changed files with 31 additions and 12 deletions
|
|
@ -884,15 +884,30 @@ Ox.Map = function(options, self) {
|
||||||
|
|
||||||
// Use current map zoom level directly as Nominatim zoom level
|
// Use current map zoom level directly as Nominatim zoom level
|
||||||
const currentMapZoom = Math.round(self.map.getZoom());
|
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');
|
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 {
|
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 response = await fetch(request);
|
||||||
const geojson = await response.json();
|
const geojson = await response.json();
|
||||||
|
|
||||||
|
|
@ -911,10 +926,10 @@ Ox.Map = function(options, self) {
|
||||||
}
|
}
|
||||||
async function forwardGeocode(config) {
|
async function forwardGeocode(config) {
|
||||||
const features = [];
|
const features = [];
|
||||||
|
const request = `${self.options.nominatim}/search?q=${
|
||||||
|
config.query
|
||||||
|
}&format=geojson&polygon_geojson=0&addressdetails=1&accept-language=en`;
|
||||||
try {
|
try {
|
||||||
const request = `${self.options.nominatim}/search?q=${
|
|
||||||
config.query
|
|
||||||
}&format=geojson&polygon_geojson=0&addressdetails=1`;
|
|
||||||
const response = await fetch(request);
|
const response = await fetch(request);
|
||||||
const geojson = await response.json();
|
const geojson = await response.json();
|
||||||
for (const feature of geojson.features) {
|
for (const feature of geojson.features) {
|
||||||
|
|
@ -1228,9 +1243,13 @@ Ox.Map = function(options, self) {
|
||||||
'state', 'county', 'region'
|
'state', 'county', 'region'
|
||||||
],
|
],
|
||||||
'city': [
|
'city': [
|
||||||
'locality', 'city', 'town'
|
'locality', 'city', 'town', 'village'
|
||||||
|
],
|
||||||
|
'borough': [
|
||||||
|
'neighborhood', 'postal_code', 'sublocality', 'suburb', 'borough'
|
||||||
|
'neighbourhood',
|
||||||
|
|
||||||
],
|
],
|
||||||
'borough': ['neighborhood', 'postal_code', 'sublocality', 'suburb', 'borough'],
|
|
||||||
'street': [
|
'street': [
|
||||||
'intersection', 'route',
|
'intersection', 'route',
|
||||||
'street_address', 'street_number',
|
'street_address', 'street_number',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue