The following tutorial provides an example of a simple 3 x 3 matrix in Berlin, Germany with these origins and destinations:
Alexanderplatz at (52.52103, 13.41268)
Brandenburg Gate at (52.51628, 13.37771)
Tempelhof Field at (52.47342, 13.40357)
To calculate a car distance matrix, you can use the request below. Since the request does not specify a destinations array, the origins are taken as destinations and the resulting matrix is a 3 x 3 matrix. The region definition is a bounding box around the waypoints with a small margin added to be able to properly route in the vicinity of the waypoints. By default, the service calculates a travel times matrix, but since we want to get distances in the response instead of times, the request specifies the matrixAttributes property with the value distances.
The response corresponds to this matrix with entries in meters:
orig\dest
1
2
3
1
0
2908
11262
2
3506
0
10207
3
11333
9414
0
AutoCircle region definition
Instead of defining a bounding box around the origins, you can request for a circle to be automatically derived. The request below is for the same as the one above, but using the autoCircle feature.
The circle contains the origins with a smaller margin:
The autoCircle has a parameter maxRadius that can be used to limit the region size that would be used to calculate matrix entries in a limited region. This is particularly helpful if you need to do one of the following:
Make sure you always get a result, even if the autoCircle would normally exceed the region size limits.
Limit response time by making sure the region does not grow too big.
For the waypoints that are matched to the margin, or outside the calculated auto autoCircle, you will instead geterrorCodes=4` for the corresponding entries.