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
|
||||
}&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']
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue