- getRoute: function (points, callback) {
- // GraphHopper Directions API documentation
- // https://graphhopper.com/api/1/docs/routing/
- return $.ajax({
- url: OSM.GRAPHHOPPER_URL,
- data: {
+ const steps = path.instructions.map(function (instr, i) {
+ const num = `<b>${i + 1}.</b> `;
+ const lineseg = line
+ .slice(instr.interval[0], instr.interval[1] + 1)
+ .map(([lat, lng]) => ({ lat, lng }));
+ return [
+ lineseg[0],
+ GH_INSTR_MAP[instr.sign],
+ num + instr.text,
+ instr.distance,
+ lineseg
+ ]; // TODO does graphhopper map instructions onto line indices?
+ });
+ steps.at(-1)[1] = 14;
+
+ return {
+ line: line,
+ steps: steps,
+ distance: path.distance,
+ time: path.time / 1000,
+ ascend: path.ascend,
+ descend: path.descend
+ };
+ }
+
+ return {
+ id: id,
+ creditline: "<a href=\"https://www.graphhopper.com/\" target=\"_blank\">GraphHopper</a>",
+ draggable: false,
+
+ getRoute: function (points, callback) {
+ // GraphHopper Directions API documentation
+ // https://graphhopper.com/api/1/docs/routing/
+ const data = {