Trying to be more robust to find the name of a locality with nominatim...
This commit is contained in:
parent
97f11239e8
commit
040c0271d7
|
@ -26,11 +26,21 @@ export const findAddress = memoize(_findAddress, {
|
|||
});
|
||||
|
||||
export const getVillageOrTown = (address: any) => {
|
||||
if (address?.address?.village) {
|
||||
return address.address.village;
|
||||
const citySynonyms = [
|
||||
'village',
|
||||
'city',
|
||||
'town',
|
||||
'municipality',
|
||||
'hamlet',
|
||||
'suburb',
|
||||
'locality',
|
||||
];
|
||||
|
||||
for (let synonym of citySynonyms) {
|
||||
console.log({ caller: 'getVillageOrTown', address, synonym });
|
||||
if (synonym in address?.address) {
|
||||
return address?.address[synonym];
|
||||
}
|
||||
if (address?.address?.city) {
|
||||
return address.address.city;
|
||||
}
|
||||
return address?.address?.town;
|
||||
return address?.address?.country;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue