]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/routing.js.erb
Using GraphHopper new API
[rails.git] / app / assets / javascripts / routing.js.erb
index 7bb27f72bdfa41685d095bd3167d9355309d56f1..5ff0656c81c99f1767c700888391a0b133a5e1e9 100644 (file)
@@ -18,7 +18,10 @@ var ROUTING_POLYLINE_HIGHLIGHT={
 
 
 OSM.RoutingEngines={
-    list: []
+    list: [],
+    add: function(supportsHTTPS,engine) {
+        if (document.location.protocol=="http:" || supportsHTTPS) this.list.push(engine);
+    }
 };
 
 OSM.Routing=function(map,name,jqSearch) {
@@ -206,18 +209,18 @@ OSM.Routing=function(map,name,jqSearch) {
             row.append("<td class='direction i"+step[1]+"'> ");
             row.append("<td class='instruction'>"+step[2]);
             row.append("<td class='distance'>"+dist);
-            with ({ num: i, ll: step[0], lineseg: step[4] }) {
-                row.on('click',function(e) { r.clickTurn(num, ll); });
+            with ({ instruction: step[2], ll: step[0], lineseg: step[4] }) {
+                row.on('click',function(e) { r.clickTurn(instruction, ll); });
                 row.hover(function(e){r.highlightSegment(lineseg);}, function(e){r.unhighlightSegment();});
             };
             $('#turnbyturn').append(row);
             cumulative+=step[3];
         }
-        $('#sidebar_content').append('<p id="routing_credit">' + r.chosenEngine.creditline + '</p>');
+        $('#sidebar_content').append('<p id="routing_credit">' + I18n.t('javascripts.directions.instructions.courtesy',{link: r.chosenEngine.creditline}) + '</p>');
 
     };
-    r.clickTurn=function(num,latlng) {
-        r.popup=L.popup().setLatLng(latlng).setContent("<p>"+(num+1)+"</p>").openOn(r.map);
+    r.clickTurn=function(instruction,latlng) {
+        r.popup=L.popup().setLatLng(latlng).setContent("<p>"+instruction+"</p>").openOn(r.map);
     };
     r.highlightSegment=function(lineseg){
         if (r.highlighted) map.removeLayer(r.highlighted);
@@ -232,7 +235,9 @@ OSM.Routing=function(map,name,jqSearch) {
         else                { return Math.round(m / 1000)  + "km"; }
     };
     r.formatTime=function(s) {
-        var d=new Date(s*1000); var h=d.getHours(); var m=d.getMinutes();
+        var m=Math.round(s/60);
+        var h=Math.floor(m/60);
+        m -= h*60;
         return h+":"+(m<10 ? '0' : '')+m;
     };