title: How to Calculate the midpoint using polyline points in google Directions Service API in NODE JS
body: <p>I used Google Directions Service API. my output for the API is </p>
  
  <pre><code>"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
                      }
                   }
  ]
  </code></pre>
  
  <p>How to Calculate the midpoint of duration_in_traffice and exact location of polyline points.</p>
  
  <p><strong>Example:</strong></p>
  
  <p>A person is traveling from A to B and other from B to A. Let the <code>duration_in_traffic</code> time be C, irrespective of the distance. Both should have the midpoint for <code>duration_in_traffic("C/2")</code>. So that both of them can meet at a point using polyline point</p>