]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/routing.js.erb
Remove some repeated-query funkiness
[rails.git] / app / assets / javascripts / routing.js.erb
index ce8ec93e8442f21c6404e98eaf7a4e7975e6516d..b6bf9f4a0cac80fa3f0070f71155d2c1e6802715 100644 (file)
@@ -6,14 +6,12 @@
        https://github.com/apmon/openstreetmap-website/compare/routing2
        https://github.com/apmon/openstreetmap-website/blob/9755c3ae0a8d0684d43760f91dc864ff42d8477a/app/views/routing/start.js.erb
 
-       *** draggable start/end markers
        *** translation (including all alerts and presentation)
        *** export GPX
        *** URL history (or do we consciously not want to support that?)
        *** spinner when waiting for result (beneath 'Go' button?)
 
        *** add YOURS engine
-       *** add GraphHopper engine
 */
 
 var TURN_INSTRUCTIONS=["",
@@ -159,10 +157,10 @@ OSM.Routing=function(map,name,jqSearch) {
        
        // Route-fetching UI
 
-       r.requestRoute=function(final) {
+       r.requestRoute=function(isFinal) {
                if (r.route_from && r.route_to) {
                        r.awaitingRoute=true;
-                       r.chosenEngine.getRoute(final,[r.route_from,r.route_to]);
+                       r.chosenEngine.getRoute(isFinal,[r.route_from,r.route_to]);
                        // then, when the route has been fetched, it'll call the engine's gotRoute function
                } else if (r.route_from==false || r.route_to==false) {
                        // we're waiting for a Nominatim response before we can request a route
@@ -220,9 +218,11 @@ OSM.Routing=function(map,name,jqSearch) {
        
        r.close=function() {
                $("#content").addClass("overlay-sidebar");
-               var remove=[r.polyline,r.popup,r.marker_from,r.marker_to];
+               r.route_from=r.route_to=null;
+               $(".query_wrapper.routing input").val("");
+               var remove=['polyline','popup','marker_from','marker_to'];
                for (var i=0; i<remove.length; i++) {
-                       if (remove[i]) map.removeLayer(remove[i]);
+                       if (r[remove[i]]) { map.removeLayer(r[remove[i]]); r[remove[i]]=null; }
                }
        };