]> git.openstreetmap.org Git - rails.git/commitdiff
Limit number of directions endpoint geocoding results to 1
authorAnton Khorev <tony29@yandex.ru>
Mon, 28 Apr 2025 23:11:25 +0000 (02:11 +0300)
committerAnton Khorev <tony29@yandex.ru>
Mon, 28 Apr 2025 23:11:25 +0000 (02:11 +0300)
app/assets/javascripts/index/directions-endpoint.js

index 97b841f1443c6dceae67daeb7845a167708159e2..785613b7a8db0212b0fe43f7bb379e5b6f379d76 100644 (file)
@@ -97,7 +97,7 @@ OSM.DirectionsEndpoint = function Endpoint(map, input, marker, dragCallback, cha
 
   function getGeocode() {
     const viewbox = map.getBounds().toBBoxString(), // <sw lon>,<sw lat>,<ne lon>,<ne lat>
 
   function getGeocode() {
     const viewbox = map.getBounds().toBBoxString(), // <sw lon>,<sw lat>,<ne lon>,<ne lat>
-          geocodeUrl = OSM.NOMINATIM_URL + "search?" + new URLSearchParams({ q: endpoint.value, format: "json", viewbox });
+          geocodeUrl = OSM.NOMINATIM_URL + "search?" + new URLSearchParams({ q: endpoint.value, format: "json", viewbox, limit: 1 });
 
     endpoint.geocodeRequest = new AbortController();
     fetch(geocodeUrl, { signal: endpoint.geocodeRequest.signal })
 
     endpoint.geocodeRequest = new AbortController();
     fetch(geocodeUrl, { signal: endpoint.geocodeRequest.signal })