$('#sidebar_content').empty();
var html=('<h2><a class="geolink" href="#" onclick="$(~.close_directions~).click();return false;">' +
'<span class="icon close"></span></a>' + I18n.t('javascripts.directions.directions') +
- '</h2><table id="turnbyturn" />').replace(/~/g,"'");
+ '</h2><p id="routing_summary">' +
+ I18n.t('javascripts.directions.distance') + ': ' + r.formatDistance(data.distance)+ '. ' +
+ I18n.t('javascripts.directions.time' ) + ': ' + r.formatTime(data.time) + '.</p>' +
+ '<table id="turnbyturn" />').replace(/~/g,"'");
$('#sidebar_content').html(html);
// Add each row
var cumulative=0;
r.clickTurn=function(num,latlng) {
r.popup=L.popup().setLatLng(latlng).setContent("<p>"+(num+1)+"</p>").openOn(r.map);
};
+ 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();
+ return h+":"+(m<10 ? '0' : '')+m;
+ };
// Close all routing UI
var distInMeter = instr.distances[i];
steps.push([{lat: latlng[0], lng: latlng[1]}, instrCode, instrText, distInMeter]);
}
- router.setItinerary({steps: steps});
+ router.setItinerary({ steps: steps, distance: data.route.distance, time: data.route['time']/1000 });
return true;
},
GH_INSTR_MAP: {
url+="&"+that.vehicleParam;
//url+="&locale=" + I18n.currentLocale(); //Doesn't actually work. MapQuest requires full locale e.g. "de_DE", but I18n only provides language, e.g. "de"
url+="&manMaps=false";
- url+="&shapeFormat=raw&generalize=0";
+ url+="&shapeFormat=raw&generalize=0&unit=k";
this.requestCORS(url);
},
gotRoute: function(router,data) {
var d=(i==mq.length-1) ? 15: this.MQ_SPRITE_MAP[s.turnType];
steps.push([L.latLng(s.startPoint.lat, s.startPoint.lng), d, s.narrative, s.distance*1000]);
}
- router.setItinerary( { steps: steps });
+ router.setItinerary( { steps: steps, distance: data.route.distance*1000, time: data.route['time'] });
return true;
}
};
if (instCodes[0]!=15) { instText+=s[1] ? "<b>"+s[1]+"</b>" : I18n.t('javascripts.directions.instructions.unnamed'); }
steps.push([line[s[3]], s[0].split('-')[0], instText, s[2]]);
}
- if (steps.length) router.setItinerary({ steps: steps });
+ if (steps.length) router.setItinerary({ steps: steps, distance: data.route_summary.total_distance, time: data.route_summary.total_time });
return true;
}
};
font-size: 13px;
}
+ p {
+ padding: 0 $lineheight $lineheight/4;
+ }
+
.icon.close {
float: right;
cursor: pointer;
mapquest_foot: "Foot (MapQuest)"
osrm_car: "Car (OSRM)"
directions: "Directions"
+ distance: "Distance"
errors:
no_route: "Couldn't find a route between those two places."
no_place: "Sorry - couldn't find that place."
against_oneway: "Go against one-way on "
end_oneway: "End of one-way on "
unnamed: "(unnamed)"
+ time: "Time"
redaction:
edit:
description: "Description"