Some search providers, especially OSM, return the address search results in a not very common order.
E. g. the house number is returned in the first position of the label, which is very uncommon in German.
Changes done
This PR introduces a callback function which is executed in order to manipulate the search result label.
Caveats
As the query is currently not available in the result list, it could not be propagated to the callback function.
Adding this would have increased the PR which I wanted to avoid.
How it looks like
Before
Provider OSM
Afterwards
with callback injected
resultFormat: (result)=>{
if(result.label.match(/^\d+,/)){
// swap house no and street
const components = result.label.split(',').map(s=>s.trim())
const houseNo = components[0]
components[0] = components[1]
components[1] = houseNo
return `${components.slice(0,2).join(' ')}, ${components.slice(2, components.length).join(', ')}`
}
return result.label
},
Motivation
Some search providers, especially OSM, return the address search results in a not very common order. E. g. the house number is returned in the first position of the label, which is very uncommon in German.
Changes done
This PR introduces a callback function which is executed in order to manipulate the search result label.
Caveats
As the query is currently not available in the result list, it could not be propagated to the callback function. Adding this would have increased the PR which I wanted to avoid.
How it looks like
Before
Provider OSM
Afterwards
with callback injected