// Doesn't yet support hints
function OSRMEngine() {
+ var previousPoints, hintData;
+
return {
- name: "javascripts.directions.engines.osrm_car",
+ id: "osrm_car",
creditline: '<a href="http://project-osrm.org/" target="_blank">OSRM</a>',
draggable: true,
- getRoute: function (isFinal, points, callback) {
+ getRoute: function (points, callback) {
var TURN_INSTRUCTIONS = [
"",
I18n.t('javascripts.directions.instructions.continue_on'), // 1
I18n.t('javascripts.directions.instructions.end_oneway') // 17
];
- var url = "http://router.project-osrm.org/viaroute?z=14&output=json";
+ var url = "http://router.project-osrm.org/viaroute?z=14&output=json&instructions=true";
for (var i = 0; i < points.length; i++) {
url += "&loc=" + points[i].lat + ',' + points[i].lng;
+ if (hintData && previousPoints && previousPoints[i].equals(points[i])) {
+ url += "&hint=" + hintData.locations[i];
+ }
}
- if (isFinal)
- url += "&instructions=true";
+ if (hintData && hintData.checksum) {
+ url += "&checksum=" + hintData.checksum;
+ }
$.ajax({
url: url,
if (data.status == 207)
return callback(true);
+ previousPoints = points;
+ hintData = data.hint_data;
+
var line = L.PolylineUtil.decode(data.route_geometry);
for (var i = 0; i < line.length; i++) {
line[i].lat /= 10;