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

reverse api for nominatim not working #341

Open
ghost opened this issue Aug 1, 2023 · 3 comments
Open

reverse api for nominatim not working #341

ghost opened this issue Aug 1, 2023 · 3 comments
Labels

Comments

@ghost
Copy link

ghost commented Aug 1, 2023

by default -4 is going in api call for reverse.

in code why log is used to calculate scale

@pablocabto
Copy link

Any updates on this? According to the Nominatin API, 18 must be set in the zoom parameter to get building-level accuracy. However, the code uses a logarithmic operation and 18 becomes -4 in the actual request.

@simon04
Copy link
Collaborator

simon04 commented Aug 27, 2023

Please see the demo for the intended use of zoom/scale:

map.on('click', function(e) {
geocoder.reverse(e.latlng, map.options.crs.scale(map.getZoom()), function(results) {
var r = results[0];
if (r) {
if (marker) {
marker
.setLatLng(r.center)
.setPopupContent(r.html || r.name)
.openPopup();
} else {
marker = L.marker(r.center)
.bindPopup(r.name)
.addTo(map)
.openPopup();
}
}
});
});

This behaviour has been around forever, more specifically since 2014, 9a0e966.

@ciuliene
Copy link

ciuliene commented Sep 13, 2023

This issue could be easily solved by setting the scale parameter as optional. Something like this:

reverse(location: L.LatLngLiteral, scale: number, cb: GeocodingCallback, context?: any) {
    const params = reverseParams(this.options, {
      lat: location.lat,
      lon: location.lng,
      zoom: scale < 0 ? undefined : Math.round(Math.log(scale / 256) / Math.log(2)),
      addressdetails: 1,
      format: 'json'
    });

See this

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

No branches or pull requests

3 participants