Open jzadra opened 5 years ago
Hello! @trafficonese - has this question been answered anywhere? I would like to do something similar in an RShiny app that I am working on. Thank you!!
I dont think it's possible currently. When you search in OSM you will always query the whole world.
The filterData
argument is only relevant for the addSearchFeatures
function.
Here is an example in the JS-library: https://github.com/stefanocudini/leaflet-search/blob/d29c5392b33cc31b338c3d17b5f8532fef5eae48/examples/fuzzy.html#L71 https://opengeo.tech/maps/leaflet-search/examples/fuzzy.html
This has to be tackled in the upstream JS repo: https://github.com/stefanocudini/leaflet-search/issues/231
Would it be enough to just add a country or state as filter? The search plugin uses the free-form-query from Nominatim
Free-form queries are processed first left-to-right and then right-to-left if that fails. So you may search for pilkington avenue, birmingham as well as for birmingham, pilkington avenue. Commas are optional, but improve performance by reducing the complexity of the search.
So the idea would be to have a restrictTo
argument that is always at the start of a query. So for example I want to restrict my queries to Austria & find all objects named Vienna, it would look like this:
https://nominatim.openstreetmap.org/search?format=json&q=Austria,Vienna
instead of just
https://nominatim.openstreetmap.org/search?format=json&q=Vienna
This should result in shorter search results and improve the search speed.
and ideally I could make the filter as long as possible..
so for example if I want to find all objects named Cannstätter in Germany and the region Neckarvorstadt:
https://nominatim.openstreetmap.org/search?format=json&q=Germany,Neckarvorstadt,Cannstätter
Unfortunately the plugin doesn't offer this option currently, but it would be a small addition and quick PR.
Is there any way to limit the search results either to the area being viewed on the map, or by hardcoding it (for instance just for North Carolina, or a certain county)?
I'm not clear on whether the filterData would allow this, as the documentation doesn't explain the arguments/parameters.