perliedman / leaflet-control-geocoder

A simple geocoder form to locate places. Easily extended to multiple data providers.
http://www.liedman.net/leaflet-control-geocoder/
BSD 2-Clause "Simplified" License
560 stars 220 forks source link

reverse api for nominatim not working #341

Open ghost opened 1 year ago

ghost commented 1 year ago

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

in code why log is used to calculate scale

pablocabto commented 1 year ago

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 commented 1 year ago

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

https://github.com/perliedman/leaflet-control-geocoder/blob/0ace940ffc30640ac99dbb0d5f42fd6ca28c9ebc/demo/index.html#L62-L79

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

ciuliene commented 1 year ago

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