Pass viewbox to Nominatim when geocoding routing endpoints
authormarc tobias <mtmail@gmx.net>
Thu, 25 Jul 2019 01:25:02 +0000 (03:25 +0200)
committerTom Hughes <tom@compton.nu>
Thu, 25 Jul 2019 18:24:36 +0000 (19:24 +0100)
Fixes #2327
Closes #2328

app/assets/javascripts/index/directions.js

index 4f79ca4..4c39d67 100644 (file)
@@ -105,7 +105,9 @@ OSM.Directions = function (map) {
 
       endpoint.awaitingGeocode = true;
 
-      $.getJSON(OSM.NOMINATIM_URL + "search?q=" + encodeURIComponent(endpoint.value) + "&format=json", function (json) {
+      var viewbox = map.getBounds().toBBoxString(); // <sw lon>,<sw lat>,<ne lon>,<ne lat>
+
+      $.getJSON(OSM.NOMINATIM_URL + "search?q=" + encodeURIComponent(endpoint.value) + "&format=json&viewbox=" + viewbox, function (json) {
         endpoint.awaitingGeocode = false;
         endpoint.hasGeocode = true;
         if (json.length === 0) {