From 8d2592fcb78d35a64d838bb4e2e92087c690cf2c Mon Sep 17 00:00:00 2001 From: mam17 Date: Fri, 25 Sep 2020 10:37:53 -0300 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20Adding=20Distance=20and=20Durat?= =?UTF-8?q?ion=20for=20each=20waypoint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MapViewDirections.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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, }); From e50312eb7ba71882191eef3c7e598fe96e979d50 Mon Sep 17 00:00:00 2001 From: mam17 Date: Fri, 25 Sep 2020 10:43:45 -0300 Subject: [PATCH 2/3] #46 Removing unused code --- src/MapViewDirections.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/MapViewDirections.js b/src/MapViewDirections.js index be2fae5..0db976d 100644 --- a/src/MapViewDirections.js +++ b/src/MapViewDirections.js @@ -277,7 +277,6 @@ class MapViewDirections extends Component { ]; }, []) ), - steps: route.legs, fare: route.fare, waypointOrder: route.waypoint_order, }); From 408ef3446b4cad2f123af8fe6819cbd5a904b39a Mon Sep 17 00:00:00 2001 From: mam17 Date: Fri, 25 Sep 2020 10:54:16 -0300 Subject: [PATCH 3/3] #46 Fixing method --- src/MapViewDirections.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MapViewDirections.js b/src/MapViewDirections.js index 0db976d..be2fae5 100644 --- a/src/MapViewDirections.js +++ b/src/MapViewDirections.js @@ -277,6 +277,7 @@ class MapViewDirections extends Component { ]; }, []) ), + steps: route.legs, fare: route.fare, waypointOrder: route.waypoint_order, });