title: I am trying to find mid point with duration traffic (based on traffic with respect to departure time)
body: <p>I am trying to find the midpoint using duration traffic values(n1,n2,n3) in specified departure time(timeStamp) so that all the three-person have the same travel time (midpoint by Time). I'm using  Google distance matrix. </p>
  
  <p>I have been passing all three locations (a,b,c) &amp; midpoint(d) based on the distance of the three locations.</p>
  
  <p>I tried finding their midpoint by subtraction(all three), average(three of them) and subtracting with (Max and Min Values of n1,n2,n3) so that there traveling time becomes equal or less than the specified time(maxTime distance b/w three of them). Then point becomes the Midpoint 
  But I couldn't find a solution. Suggestions are much appreciated.</p>
  
  <pre><code>const maxTime = 5000;
  var i = 0;
  z = 0;
  j = 0
  
  //Distance Matrix Api
  function getDistanceMatrix(a, b, c, d, timeStamp, googleWarnings, copyRights) {
    clientMap.post(config_KEYS.DISTANCE_MATRIX_API + a + "|" + b + "|" + c + "&amp;destinations=" + d.lat + "," + d.lng + "+&amp;key=" + config_KEYS.GOOGLE_API_KEY + "&amp;departure_time=" + timeStamp + "", function(gotDistanceResp, err) {
      if (err) {
        res.status(400).json(gotDistanceResp)
      } else {
        let n1 = gotDistanceResp.rows[0].elements[0].duration_in_traffic.value
        let n2 = gotDistanceResp.rows[1].elements[0].duration_in_traffic.value
        let n3 = gotDistanceResp.rows[2].elements[0].duration_in_traffic.value
        // let minTime = Math.abs(n2 - n1)
        let minTime = Math.round((n3 + n2 + n1) / 3)
        if (n1 &gt;= n2 &amp;&amp; n1 &gt;= n3) {
          if (minTime &lt;= maxTime) {
            res.send(gotDistanceResp)
          } else {
            i++;
            let arrayPoints = getDirectionApi(a, d, timeStamp, i)
          }
        } else {
          if (n2 &gt;= n1 &amp;&amp; n2 &gt;= n3) {
            if (minTime &lt;= maxTime) {
              res.send(gotDistanceResp)
            } else {
              j++;
              let arrayPoints = getDirectionApi(b, d, timeStamp, j)
            }
          } else {
            if (n3 &gt;= n1 &amp;&amp; n3 &gt;= n1) {
              if (minTime &lt;= maxTime) {
                res.send(gotDistanceResp)
              } else {
                z++;
                let arrayPoints = getDirectionApi(c, d, timeStamp, z)
              }
            } else {
              res.send(gotDistanceResp)
            }
          }
        }
      }
    })
  }
  //Get Direction Api
  function getDirectionApi(a, b, timeStamp, r) {
    clientMap.post(config_KEYS.DIRECTION_API + a + "&amp;destination=" + b.lat + "," + b.lng + "&amp;key=" + config_KEYS.GOOGLE_API_KEY + "&amp;departure_time=" + timeStamp + "", function(route, error) {
      if (route.geocoder_status == "ZERO_RESULTS" | route.status == "INVALID_REQUEST") {
        res.status(400).send(route)
      } else {
        let googleWarnings = route.routes[0].warnings
        let copyRights = route.routes[0].copyrights
        let polyline = route.routes[0].overview_polyline.points
        let decoded = decode(polyline)
        let midPointCha = getDistanceMatrix(Location1, Location2, Location3, reversedMidArra[r])
      }
    })
  }
  </code></pre>