Add line segment to each steps of GraphHopper routing
authorNicolas Cornu <ncornu@aldebaran.com>
Thu, 16 Feb 2017 20:14:17 +0000 (21:14 +0100)
committerNicolas Cornu <ncornu@aldebaran.com>
Thu, 16 Feb 2017 20:19:55 +0000 (21:19 +0100)
app/assets/javascripts/index/directions/graphhopper.js

index 88a9c15c1215b00ae19ba6a7373eb88dff1efd7c..267b1b4a6af09919423899e2eee921ee39ce978f 100644 (file)
@@ -49,12 +49,16 @@ function GraphHopperEngine(id, vehicleType) {
             instrText += instr.text;
             var latLng = line[instr.interval[0]];
             var distInMeter = instr.distance;
+            var lineseg = [];
+            for (var j = instr.interval[0]; j <= instr.interval[1]; j++) {
+              lineseg.push({lat: line[j][0], lng: line[j][1]});
+            }
             steps.push([
               {lat: latLng.lat, lng: latLng.lng},
               instrCode,
               instrText,
               distInMeter,
-              []
+              lineseg
             ]); // TODO does graphhopper map instructions onto line indices?
           }