]> git.openstreetmap.org Git - rails.git/commitdiff
Introduce geocode event callback for route endpoints
authorAnton Khorev <tony29@yandex.ru>
Sat, 15 Jun 2024 19:04:15 +0000 (22:04 +0300)
committerAnton Khorev <tony29@yandex.ru>
Sat, 15 Jun 2024 19:26:23 +0000 (22:26 +0300)
Removes remaining getRoute() call from endpoint objects.

app/assets/javascripts/index/directions.js

index 8d9263323e44c154f60a77ede80f1eb8425da3df..ae01cb566f5732fcb088900ad7c028aa2d7a43b7 100644 (file)
@@ -25,10 +25,13 @@ OSM.Directions = function (map) {
       getRoute(false, !dragging);
     }
   };
+  var endpointGeocodeCallback = function () {
+    getRoute(true, true);
+  };
 
   var endpoints = [
-    Endpoint($("input[name='route_from']"), OSM.MARKER_GREEN, endpointDragCallback),
-    Endpoint($("input[name='route_to']"), OSM.MARKER_RED, endpointDragCallback)
+    Endpoint($("input[name='route_from']"), OSM.MARKER_GREEN, endpointDragCallback, endpointGeocodeCallback),
+    Endpoint($("input[name='route_to']"), OSM.MARKER_RED, endpointDragCallback, endpointGeocodeCallback)
   ];
 
   var expiry = new Date();
@@ -48,7 +51,7 @@ OSM.Directions = function (map) {
     select.append("<option value='" + i + "'>" + I18n.t("javascripts.directions.engines." + engine.id) + "</option>");
   });
 
-  function Endpoint(input, iconUrl, dragCallback) {
+  function Endpoint(input, iconUrl, dragCallback, geocodeCallback) {
     var endpoint = {};
 
     endpoint.marker = L.marker([0, 0], {
@@ -119,7 +122,7 @@ OSM.Directions = function (map) {
 
         input.val(json[0].display_name);
 
-        getRoute(true, true);
+        geocodeCallback();
       });
     };