leaflet-geosearch
leaflet-geosearch copied to clipboard
Add support for fallback providers
Just had the issue that nominatim was not reachable.
I was wondering if it is possible to catch such errors and fallback to other providers in that case (or to catch the error and show some message)
I did not find anything that would relate to such problems in the code, but maybe I am missing something... if so, I guess it would be a good idea to add a small sample to the docs :-)
HI @nikolauskrismer , thanks for opening this issue. Please may I know how you solved this issue? I'm currently experiencing a similar error with nominatim. Thanks
@jeafreezy To be honest, I don't think that original issue will be the same as yours. Just describe your problem here a bit wider. Providing demo (like JSFiddle) will be awesome.
@smeijer I think "Providers fallback" will be good title for this issue, don’t you think? Also, it maybe related to issue https://github.com/smeijer/leaflet-geosearch/issues/153 (in both case we are manipulating with multiple providers)
Yeah, I think this "error handling" should be solved by wrapping one or more providers. See also https://github.com/smeijer/leaflet-geosearch/issues/153#issuecomment-348686251.
The docs have an example on how to use a single provider directly. That one should be extended with searching in the fallback provider, if the first doesn't have results.
https://smeijer.github.io/leaflet-geosearch/usage#using-the-providers-directly
That being said, I doubt that provider 2 will have results, when provider 1 doesn't. Thereby, I don't really feel for adding native support for that.
I'm willing to reconsider if someone can come up with concrete examples of "x has no results for ..., but provider y has".
Thank you @yuriizinets for the swift response. Unfortunately, I didn't take a screenshot of the error, but the error code was 400. My search box was making a request using the OpenStreetMaps provider and at that time the server was returning an error code. It's working fine now but my concern is that this should not happen in production and if at all it does, is there away I can catch such an error so I can display to the users some text e.g "THe server is down at the moment,kindly check back later" . Thanks
We currently don't have a handler for those kind of errors. That's something that should definitely be added. I've created #245 to cover that change.
Thank you @smeijer !