diff --git a/src/MapViewDirections.js b/src/MapViewDirections.js index ac08d73..be2fae5 100644 --- a/src/MapViewDirections.js +++ b/src/MapViewDirections.js @@ -184,7 +184,7 @@ class MapViewDirections extends Component { ); })).then(results => { // Combine all Directions API Request results into one - const result = results.reduce((acc, { distance, duration, coordinates, fare, waypointOrder }) => { + const result = results.reduce((acc, { distance, duration, coordinates, fare, waypointOrder, steps }) => { acc.coordinates = [ ...acc.coordinates, ...coordinates, @@ -199,6 +199,13 @@ class MapViewDirections extends Component { ...acc.waypointOrder, waypointOrder, ]; + acc.splitedSteps = steps.reduce((accumulator, step) => [ + ...accumulator, + { + distance: step.distance.value, + duration: step.duration.value, + }, + ], []); return acc; }, { @@ -207,6 +214,7 @@ class MapViewDirections extends Component { duration: 0, fares: [], waypointOrder: [], + splitedSteps: [], }); // Plot it out and call the onReady callback @@ -269,6 +277,7 @@ class MapViewDirections extends Component { ]; }, []) ), + steps: route.legs, fare: route.fare, waypointOrder: route.waypoint_order, });