]> git.openstreetmap.org Git - rails.git/commitdiff
Allow lat/lon from the URL to take precedence when routing
authorTom Hughes <tom@compton.nu>
Sat, 3 Feb 2018 16:39:39 +0000 (16:39 +0000)
committerTom Hughes <tom@compton.nu>
Sat, 3 Feb 2018 16:39:39 +0000 (16:39 +0000)
app/assets/javascripts/index/directions.js

index 093afe30a9148836ac63a39cd985ee2b3538ae47..ce8ac9c1cc432a0e61a081c70f67ab21987b5bf3 100644 (file)
@@ -60,11 +60,16 @@ OSM.Directions = function (map) {
       endpoint.setValue(value);
     });
 
       endpoint.setValue(value);
     });
 
-    endpoint.setValue = function(value) {
+    endpoint.setValue = function(value, latlng) {
       endpoint.value = value;
       delete endpoint.latlng;
       input.val(value);
       endpoint.value = value;
       delete endpoint.latlng;
       input.val(value);
-      endpoint.getGeocode();
+
+      if (latlng) {
+        endpoint.setLatLng(latlng);
+      } else {
+        endpoint.getGeocode();
+      }
     };
 
     endpoint.getGeocode = function() {
     };
 
     endpoint.getGeocode = function() {
@@ -359,22 +364,18 @@ OSM.Directions = function (map) {
     });
 
     var params = querystring.parse(location.search.substring(1)),
     });
 
     var params = querystring.parse(location.search.substring(1)),
-      route = (params.route || '').split(';');
+        route = (params.route || '').split(';'),
+        from = route[0] && L.latLng(route[0].split(',')),
+        to = route[1] && L.latLng(route[1].split(','));
 
     if (params.engine) {
       setEngine(params.engine);
     }
 
 
     if (params.engine) {
       setEngine(params.engine);
     }
 
-    endpoints[0].setValue(params.from || "");
-    endpoints[1].setValue(params.to || "");
-
-    var o = route[0] && L.latLng(route[0].split(',')),
-        d = route[1] && L.latLng(route[1].split(','));
-
-    if (o) endpoints[0].setLatLng(o);
-    if (d) endpoints[1].setLatLng(d);
+    endpoints[0].setValue(params.from || "", from);
+    endpoints[1].setValue(params.to || "", to);
 
 
-    map.setSidebarOverlaid(!o || !d);
+    map.setSidebarOverlaid(!from || !to);
 
     getRoute();
   };
 
     getRoute();
   };