diff --git a/WebContent/main.js b/WebContent/main.js index 2c0e81b0f..99ec8530e 100644 --- a/WebContent/main.js +++ b/WebContent/main.js @@ -27,7 +27,7 @@ OSRM.init = function() { OSRM.Localization.init(); OSRM.GUI.init(); OSRM.Map.init(); - //OSRM.Printing.init(); + OSRM.Printing.init(); OSRM.Routing.init(); // check if the URL contains some GET parameter, e.g. for showing a route diff --git a/WebContent/printing/OSRM.Printing.js b/WebContent/printing/OSRM.Printing.js index 30a7f798c..90974d988 100644 --- a/WebContent/printing/OSRM.Printing.js +++ b/WebContent/printing/OSRM.Printing.js @@ -36,15 +36,29 @@ init: function() { }, windowLoaded: function(){ - OSRM.printwindow.initialize(); OSRM.Printing.show( OSRM.G.response ); OSRM.printwindow.focus(); }, show: function(response) { + // create header + header = + '
' + + '
' + + '
' + OSRM.loc("ROUTE_DESCRIPTION") + '
' + + '
' + OSRM.loc("DISTANCE")+": " + OSRM.Utils.metersToDistance(response.route_summary.total_distance) + '
' + + '
' + OSRM.loc("DURATION")+": " + OSRM.Utils.secondsToTime(response.route_summary.total_time) + '
' + + '
' + + '
' + + '
' + + '
'; + // create route description - var route_desc = ""; - route_desc += ''; + var route_desc = ''; + route_desc += '
'; + route_desc += ''; + route_desc += ''; + route_desc += ''; for(var i=0; i < response.route_instructions.length; i++){ //odd or even ? @@ -54,20 +68,21 @@ show: function(response) { route_desc += ''; route_desc += '"; route_desc += '"; route_desc += '"; route_desc += ""; - } - - route_desc += '
'+header+'
'; - route_desc += ''; + route_desc += ''; route_desc += "'; - route_desc += ''; - route_desc += response.route_instructions[i][0]; + route_desc += '
'; + + // build route description if( i == 0 ) - route_desc += ' ' + OSRM.loc( response.route_instructions[i][6] ); - if( response.route_instructions[i][1] != "" ) { - route_desc += ' on '; - route_desc += '' + response.route_instructions[i][1] + ''; - } - //route_desc += ' for '; - route_desc += ''; + route_desc += OSRM.loc(OSRM.RoutingDescription.getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"$1").replace(/%s/, OSRM.loc(response.route_instructions[i][6]) ); + else if( response.route_instructions[i][1] != "" ) + route_desc += OSRM.loc(OSRM.RoutingDescription.getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,"$1").replace(/%s/, response.route_instructions[i][1]); + else + route_desc += OSRM.loc(OSRM.RoutingDescription.getDrivingInstruction(response.route_instructions[i][0])).replace(/\[(.*)\]/,""); + + route_desc += '
'; route_desc += "
'; @@ -76,29 +91,31 @@ show: function(response) { route_desc += "
'; - headline = ""; - headline += OSRM.loc("ROUTE_DESCRIPTION")+":
"; - headline += '
'; - headline += "" - + OSRM.loc("DISTANCE")+": " + OSRM.Utils.metersToDistance(response.route_summary.total_distance) - + "
" - + OSRM.loc("DURATION")+": " + OSRM.Utils.secondsToTime(response.route_summary.total_time) - + "
"; - headline += '
'; - - var output = ""; - output += route_desc; - - OSRM.printwindow.document.getElementById('description-headline').innerHTML = headline; - OSRM.printwindow.document.getElementById('description').innerHTML = output; + } + route_desc += ''; + route_desc += ''; + + // put everything in DOM + OSRM.printwindow.document.getElementById('description').innerHTML = route_desc; + + // init map + var map = OSRM.printwindow.initialize(); + var markers = OSRM.G.markers.route; + map.addLayer( new L.MouseMarker( markers[0].getPosition(), {draggable:false,clickable:false,icon:OSRM.G.icons['marker-source']} ) ); + for(var i=1, size=markers.length-1; i +