Matrix

Compute Distance and Duration Matrix

Calculates a matrix of travel times and distances between multiple geographic points. This is useful for logistics, delivery optimization, or any application requiring pairwise route calculations between several origins and destinations.

GET
/api/route/matrix

Calculates a matrix of travel times and distances between multiple geographic points. This is useful for logistics, delivery optimization, or any application requiring pairwise route calculations between several origins and destinations.

Query Parameters

json*string

A list of coordinate pairs in the format [{lat1,lon1},{lat2,lon2},...]. These coordinates are used as both origins and destinations to compute the matrix.

apiKey*string

API key used for authentication and access control.

Response Body

Travel time and distance between every pair of points.

application/json
  1. response
origins?array<>

The origins, snapped to the nearest road.

destinations?array<>

The destinations, snapped to the nearest road.

origin_to_destination?array<>

One entry per origin and destination pair.

curl -X GET 'https://mapapi.gebeta.app/api/route/matrix?json=%5B%7B8.987685259188599%2C38.764792722654455%7D%2C%7B8.9879443%2C38.7651287%7D%2C%7B9.087685259188599%2C38.764792722654455%7D%5D&apiKey=your-api-key-here'
{  "origins": [    {      "lat": 9.055978,      "lon": 38.704943,      "radius": null    },    {      "lat": 9.030787,      "lon": 38.730911,      "radius": null    },    {      "lat": 9.047874,      "lon": 38.756519,      "radius": null    }  ],  "destinations": [    {      "lat": 9.055978,      "lon": 38.704943,      "radius": null    },    {      "lat": 9.030787,      "lon": 38.730911,      "radius": null    },    {      "lat": 9.047874,      "lon": 38.756519,      "radius": null    }  ],  "origin_to_destination": [    {      "from": 0,      "to": 0,      "distance": 0,      "time": 0    },    {      "from": 0,      "to": 1,      "distance": 6.067,      "time": 878    },    {      "from": 0,      "to": 2,      "distance": 9.547,      "time": 1264    },    {      "from": 1,      "to": 0,      "distance": 6.795,      "time": 971    },    {      "from": 1,      "to": 1,      "distance": 0,      "time": 0    },    {      "from": 1,      "to": 2,      "distance": 4.393,      "time": 641    },    {      "from": 2,      "to": 0,      "distance": 8.699,      "time": 1144    },    {      "from": 2,      "to": 1,      "distance": 4.307,      "time": 614    },    {      "from": 2,      "to": 2,      "distance": 0,      "time": 0    }  ]}