From 920a596fb2e024d480c4f2f2d71ba2d942567421 Mon Sep 17 00:00:00 2001 From: shubham dhumal Date: Sat, 18 Sep 2021 00:10:30 +0530 Subject: [PATCH] I have added source and desination Address in porps onReady call back function --- src/MapViewDirections.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/MapViewDirections.js b/src/MapViewDirections.js index ac08d73..f37da40 100644 --- a/src/MapViewDirections.js +++ b/src/MapViewDirections.js @@ -184,13 +184,15 @@ 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, sourceAddress, destinationAddress }) => { acc.coordinates = [ ...acc.coordinates, ...coordinates, ]; acc.distance += distance; acc.duration += duration; + acc.sourceAddress = sourceAddress; + acc.destinationAddress = destinationAddress; acc.fares = [ ...acc.fares, fare, @@ -199,14 +201,20 @@ class MapViewDirections extends Component { ...acc.waypointOrder, waypointOrder, ]; - + acc.steps = [ + ...acc.steps, + ...steps, + ]; return acc; }, { coordinates: [], distance: 0, duration: 0, fares: [], + sourceAddress:'', + destinationAddress: '', waypointOrder: [], + steps:[], }); // Plot it out and call the onReady callback @@ -271,6 +279,8 @@ class MapViewDirections extends Component { ), fare: route.fare, waypointOrder: route.waypoint_order, + sourceAddress: route.legs[0].start_address, + destinationAddress: route.legs[0].end_address, }); } else {