X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/b095b59d5e0ee805e49980af80b21bd1acff1345..873c1cb84e2fe475bc4ff566d71929fdcc35787d:/app/assets/javascripts/routing.js.erb diff --git a/app/assets/javascripts/routing.js.erb b/app/assets/javascripts/routing.js.erb index d62e94f0c..5ff0656c8 100644 --- a/app/assets/javascripts/routing.js.erb +++ b/app/assets/javascripts/routing.js.erb @@ -10,9 +10,18 @@ var ROUTING_POLYLINE={ weight: 10 }; +var ROUTING_POLYLINE_HIGHLIGHT={ + color: '#ff0', + opacity: 0.5, + weight: 12 +}; + OSM.RoutingEngines={ - list: [] + list: [], + add: function(supportsHTTPS,engine) { + if (document.location.protocol=="http:" || supportsHTTPS) this.list.push(engine); + } }; OSM.Routing=function(map,name,jqSearch) { @@ -171,7 +180,7 @@ OSM.Routing=function(map,name,jqSearch) { }; // Take directions and write them out - // data = { steps: array of [latlng, sprite number, instruction text, distance in metres] } + // data = { steps: array of [latlng, sprite number, instruction text, distance in metres, highlightPolyline] } // sprite numbers equate to OSRM's route_instructions turn values r.setItinerary=function(data) { // Create base table @@ -200,25 +209,35 @@ OSM.Routing=function(map,name,jqSearch) { row.append("
' + r.chosenEngine.creditline + '
'); + $('#sidebar_content').append('' + I18n.t('javascripts.directions.instructions.courtesy',{link: r.chosenEngine.creditline}) + '
'); }; - r.clickTurn=function(num,latlng) { - r.popup=L.popup().setLatLng(latlng).setContent(""+(num+1)+"
").openOn(r.map); + r.clickTurn=function(instruction,latlng) { + r.popup=L.popup().setLatLng(latlng).setContent(""+instruction+"
").openOn(r.map); }; + r.highlightSegment=function(lineseg){ + if (r.highlighted) map.removeLayer(r.highlighted); + r.highlighted=L.polyline(lineseg, ROUTING_POLYLINE_HIGHLIGHT).addTo(r.map); + } + r.unhighlightSegment=function(){ + if (r.highlighted) map.removeLayer(r.highlighted); + } r.formatDistance=function(m) { if (m < 1000 ) { return Math.round(m) + "m"; } else if (m < 10000) { return (m/1000.0).toFixed(1) + "km"; } 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; };