Skip to content
GuidesPlaygroundDashboard

Calculate a distance matrix between points

MatrixResult Routing.Matrix(RoutingMatrixParamsparameters, CancellationTokencancellationToken = default)
POST/api/v1/matrix

Calculate a distance matrix between points

ParametersExpand Collapse
RoutingMatrixParams parameters
required GeoJsonGeometry destinations

Destination points (GeoJSON MultiPoint geometry)

required GeoJsonGeometry origins

Origin points (GeoJSON MultiPoint geometry)

Mode mode

Travel mode

"auto"Auto
"foot"Foot
"bicycle"Bicycle
ReturnsExpand Collapse
class MatrixResult:
required IReadOnlyList<IReadOnlyList<Double>> Distances

Distance matrix (meters), origins x destinations

required IReadOnlyList<IReadOnlyList<Double>> Durations

Duration matrix (seconds), origins x destinations

Calculate a distance matrix between points

RoutingMatrixParams parameters = new()
{
    Destinations = new()
    {
        Coordinates = new(

            [
                0
            ]
        ),
        Type = Type.Point,
    },
    Origins = new()
    {
        Coordinates = new(

            [
                0
            ]
        ),
        Type = Type.Point,
    },
};

var matrixResult = await client.Routing.Matrix(parameters);

Console.WriteLine(matrixResult);
{
  "distances": [
    [
      0
    ]
  ],
  "durations": [
    [
      0
    ]
  ]
}
Returns Examples
{
  "distances": [
    [
      0
    ]
  ],
  "durations": [
    [
      0
    ]
  ]
}