Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No results are returned when using format: "geocodejson" #361

Open
kendlbat opened this issue Jan 2, 2025 · 1 comment
Open

No results are returned when using format: "geocodejson" #361

kendlbat opened this issue Jan 2, 2025 · 1 comment

Comments

@kendlbat
Copy link

kendlbat commented Jan 2, 2025

We would like to use the following geocoder:

var nominatim = L.Control.Geocoder.nominatim({
    reverseQueryParams: {
        format: "geocodejson",
        addressdetails: 1,
        "accept-language": "de-AT,de-DE",
    },
    geocodingQueryParams: {
        countrycodes: "at",
        "accept-language": "de-AT,de-DE",
    },
});

But when doing a reverse geocode lookup, an empty array is returned due to the following if-statement (this is minified JS so not very helpful):
image

The chain of failures is the following:

  • NominatimResult (defined here) is incorrect and does not account for different format flags being used, which further leads to incorrect expectations about the data returned by Nominatim.
  • reverse (defined here) incorrectly assumes that lat and lon are present in the returned data and returns an empty array instead of a) useful error information or b) data.

image

My suggestions are:

  • Correct this behaviour and return the expected result in the "geocodejson"-format. (Recommended)
  • Document this incorrect and unexpected behaviour and alter the L.Control.Geocoder.nominatim options to respond with an error when trying to pass the "geocodejson" format.

Update:
The response from nominatim when using the "geocodejson"-format looks like the following:
image

@simon04
Copy link
Collaborator

simon04 commented Jan 2, 2025

Hi,

yeah, the error handling should be improved overall in leaflet-control-geocoder.

Nominatim support a bunch of different output formats, see https://nominatim.org/release-docs/latest/api/Output/. Currently, only the default JSON is supported. Being curios, why are you overriding the format to GeocodeJSON?

Would you like to work on some pull requests?

Cheers from Tyrol! 🇦🇹

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants