faster lookup, start to map addresstype to type
This commit is contained in:
parent
bbc8debf46
commit
e274d88c2b
1 changed files with 16 additions and 9 deletions
|
|
@ -895,7 +895,7 @@ Ox.Map = function(options, self) {
|
||||||
config.lat
|
config.lat
|
||||||
}&lon=${
|
}&lon=${
|
||||||
config.lng
|
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 response = await fetch(request);
|
||||||
const geojson = await response.json();
|
const geojson = await response.json();
|
||||||
|
|
@ -918,7 +918,7 @@ Ox.Map = function(options, self) {
|
||||||
try {
|
try {
|
||||||
const request = `${self.options.nominatim}/search?q=${
|
const request = `${self.options.nominatim}/search?q=${
|
||||||
config.query
|
config.query
|
||||||
}&format=geojson&polygon_geojson=1&addressdetails=1`;
|
}&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) {
|
||||||
|
|
@ -1185,7 +1185,7 @@ Ox.Map = function(options, self) {
|
||||||
map: that,
|
map: that,
|
||||||
north: northEast.lat,
|
north: northEast.lat,
|
||||||
south: southWest.lat,
|
south: southWest.lat,
|
||||||
type: getType(data.address_components[0].types),
|
type: getType(data.address_components[0].types, data),
|
||||||
west: southWest.lng
|
west: southWest.lng
|
||||||
};
|
};
|
||||||
place.geoname = data.formatted_address || place.fullGeoname;
|
place.geoname = data.formatted_address || place.fullGeoname;
|
||||||
|
|
@ -1218,19 +1218,26 @@ Ox.Map = function(options, self) {
|
||||||
) ? name : null;
|
) ? name : null;
|
||||||
}).join(', ');
|
}).join(', ');
|
||||||
}
|
}
|
||||||
function getType(types) {
|
function getType(types, data) {
|
||||||
// see https://developers.google.com/maps/documentation/javascript/geocoding#GeocodingAddressTypes
|
// see https://developers.google.com/maps/documentation/javascript/geocoding#GeocodingAddressTypes
|
||||||
|
types.push(data.properties.addresstype)
|
||||||
|
|
||||||
var strings = {
|
var strings = {
|
||||||
'country': ['country'],
|
'country': ['country'],
|
||||||
'region': ['administrative_area', 'colloquial_area'],
|
'region': [
|
||||||
'city': ['locality'],
|
'administrative_area', 'colloquial_area',
|
||||||
'borough': ['neighborhood', 'postal_code', 'sublocality'],
|
'state', 'county'
|
||||||
|
],
|
||||||
|
'city': ['locality', 'city'],
|
||||||
|
'borough': ['neighborhood', 'postal_code', 'sublocality', 'suburb', 'borough'],
|
||||||
'street': [
|
'street': [
|
||||||
'intersection', 'route',
|
'intersection', 'route',
|
||||||
'street_address', 'street_number'
|
'street_address', 'street_number',
|
||||||
|
'road',
|
||||||
],
|
],
|
||||||
'building': [
|
'building': [
|
||||||
'airport', 'floor', 'premise', 'room', 'subpremise'
|
'airport', 'floor', 'premise', 'room', 'subpremise',
|
||||||
|
'building',
|
||||||
],
|
],
|
||||||
'feature': ['natural_feature', 'park']
|
'feature': ['natural_feature', 'park']
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue