- // Draw polyline
- var path = data.paths[0];
- var line = L.PolylineUtil.decode(path.points);
- router.setPolyline(line);
- // Assemble instructions
- var steps = [];
- var len = path.instructions.length;
- for (i = 0; i < len; i++) {
- var instr = path.instructions[i];
- var instrCode = (i === len - 1) ? 15 : this.GH_INSTR_MAP[instr.sign];
- var instrText = "<b>" + (i + 1) + ".</b> ";
- instrText += instr.text;
- var latLng = line[instr.interval[0]];
- var distInMeter = instr.distance;
- steps.push([
- {lat: latLng.lat, lng: latLng.lng},
- instrCode,
- instrText,
- distInMeter,
- []
- ]); // TODO does graphhopper map instructions onto line indices?
- }
- router.setItinerary({ steps: steps, distance: path.distance, time: path.time / 1000 });
- return true;
- },
+ var path = data.paths[0];
+ var line = L.PolylineUtil.decode(path.points);
+
+ var steps = [];
+ var len = path.instructions.length;
+ for (var i = 0; i < len; i++) {
+ var instr = path.instructions[i];
+ var instrCode = (i === len - 1) ? 15 : GH_INSTR_MAP[instr.sign];
+ var instrText = "<b>" + (i + 1) + ".</b> ";
+ instrText += instr.text;
+ var latLng = line[instr.interval[0]];
+ var distInMeter = instr.distance;
+ steps.push([
+ {lat: latLng.lat, lng: latLng.lng},
+ instrCode,
+ instrText,
+ distInMeter,
+ []
+ ]); // TODO does graphhopper map instructions onto line indices?
+ }