title: Can Google Maps API calculate route along multiple locations or journey legs?
body: <p>I'm using the Google Maps API Web Services <a href="https://developers.google.com/maps/documentation/directions/" rel="nofollow noreferrer">Directions API</a> or the <a href="https://developers.google.com/maps/documentation/distance-matrix/" rel="nofollow noreferrer">Distance Matrix API</a> to find the travel distance and time between locations.</p>
  
  <p>It seems that the API only supports calculation of the route between one origin and one destination. (In case of the Distance Matrix API, multiple combinations directly between origins and destinations are computed.)</p>
  
  <p>My case is that I would like to know the route (really, just traveling time and distance) of a multiple-leg journey along a series (as in an ordered array) of locations.</p>
  
  <p>So, considering four locations, <code>A</code>, <code>B</code>, <code>C</code>, <code>D</code>, I know how to compute the route between any pair, <code>A-B</code>, <code>A-C</code>, <code>A-D</code>, <code>B-C</code> and so on. I want to compute the route of <code>A-B-C-D</code> or <code>A-C-D-B</code> or <code>A-D-B-C</code>and so on. I supply the route and the order of the legs, so I'm not asking to solve the Traveling Salesman Problem.</p>
  
  <p>Is this possible with the Google Maps Directions API or Distance Matrix API?</p>
  
  <p>Obviously, I can chain the locations myself, so ask for the routes of the individual legs in separate calls, and then add them together in the desired order: <code>A-C</code> + <code>C-D</code> + <code>D-B</code> becomes <code>A-C-D-B</code>. I'm hoping that it's possible with one call.</p>
  
  <p>(I've looked for similar questions, but haven't found this exact one.)</p>