How to Calculate the midpoint using polyline points in google Directions Service API in NODE JS

I used Google Directions Service API. my output for the API is

"legs": [
                    "distance": {
                        "text": "382 mi",
                        "value": 614548
                    "duration": {
                        "text": "5 hours 47 mins",
                        "value": 20799
                    "duration_in_traffic": {
                        "text": "5 hours 49 mins",
                        "value": 20915

How to Calculate the midpoint of duration_in_traffice and exact location of polyline points.


A person is traveling from A to B and other from B to A. Let the duration_in_traffic time be C, irrespective of the distance. Both should have the midpoint for duration_in_traffic("C/2"). So that both of them can meet at a point using polyline point