• Optimization
  • Navigation
  • Tracking
  • Maps
  • Places

Distance Matrix Examples


Basic Distance Matrix Fast Request

Let’s create a simple Distance Matrix Fast request with 3 `origins` (O) and 3 `destinations` (D). We will get a 3 x 3 matrix with `distance` and `duration` values for all 9 combinations (or elements) of O x D pairs. We also set `mode=car’ to get distance and duration values for a route that a car can take

Basic Distance Matrix Fast - POST Request

Let’s see how to build a Distance Matrix POST method request for the same scenario from curbside example

Basic Distance Matrix Flexible - POST Request

Let’s see how to build a Distance Matrix Flexible POST method request for the same scenario from the trips in future example

Avoid tolls for a truck

In this example, we will add a 4 x 5 matrix with 4 origins and 5 destinations which would result in a total of 20 combinations (or elements) in the response with each containing distance and duration for respective combination of locations. We will also customize our request

Approach destinations on curbside

In this example, we take a 3 x 3 matrix with 3 origins and 3 destinations which would result in a total of 9 combinations (or elements) in the response. We will also customize our request

ETAs for trips in future

For a Distance Matrix Flexible request with 4 `origins` (O) and 3 `destinations` (D) we will get a 4 x 3 matrix with `distance` and `duration` values for all 12 combinations (or elements) of O x D pairs.

ETAs for custom truck dimensions

In this example, we take a 3 x 3 matrix with 3 origins and 3 destinations which would result in a total of 9 combinations (or elements) in the response. We will also customize our request and set

Avoid service roads for trucks

In this example, let’s request for distance and duration values for a route that a truck can take while avoiding service roads. We will create a Distance Matrix Flexible request with 2 `origins` (O) and 2 `destinations` (D)

ETAs for cross-border trips

In this example, let’s request for distance and duration values for a route that a truck can take when allowed to cross country borders. We will create a Distance Matrix Flexible request with 2 `origins` (O) and 2 `destinations` (D)