Matrix API computes the road distance and the travel time between every pair of locations in a set, in one request. With the Matrix API, you can:
Returns the distance in meters and the duration in seconds of the fastest route from every waypoint to every waypoint. Row i holds the values from waypoint i, column j the values to waypoint j; the diagonal is 0. A pair with no route between its waypoints has null in both matrices.
Matrix parameters
| transport | string Default: "car" Enum: "car" "truck" "pedestrian" "bike" transport mode. Every value of the matrix is the fastest route for this transport mode | ||
| waypoints required | Array of numbers [ 2 .. 5000 ] items [ items <double > = 2 items [ items <double > ] ] the locations, each as [ lon, lat ] ( longitude first ). At least 2 and at most 5000; N waypoints give N x N values. The same location may appear more than once ( 0 between its copies ). Every waypoint must be matched to the road network of the transport mode, otherwise the request returns an error with code -19 ( HTTP 422 ) instead of a matrix | ||
| profile | string Default: "city" Enum: "road" "cross" "city" "mountain" bike profile, for | ||
object vehicle characteristics; only | |||
| |||
| debug | boolean Default: false if true, the response is pretty-printed | ||
object | |||||||
| |||||||
object (errorObject) the error, returned instead of the matrices | |||||||
| |||||||
| distances | Array of integers or null[ items ] distance matrix in meters. Row | ||||||
| durations | Array of integers or null[ items ] duration matrix in seconds, the same layout as | ||||||
object | |||||||
| |||||||
required | object (errorObject) the error, returned instead of the matrices | ||||||
| |||||||
object | |||||||
| |||||||
required | object (errorObject) the error, returned instead of the matrices | ||||||
| |||||||
object | |||||||
| |||||||
required | object (errorObject) the error, returned instead of the matrices | ||||||
| |||||||
object | |||||||
| |||||||
required | object (errorObject) the error, returned instead of the matrices | ||||||
| |||||||
object | |||||||
| |||||||
required | object (errorObject) the error, returned instead of the matrices | ||||||
| |||||||
{- "transport": "car",
- "waypoints": [
- [
- 4.3517,
- 50.8503
], - [
- 4.4025,
- 51.2194
], - [
- 5.5797,
- 50.6326
]
]
}{- "info": {
- "copyrights": [
- "MagicLane"
]
}, - "distances": [
- [
- 0,
- 55393,
- 97517
], - [
- 44793,
- 0,
- 133347
], - [
- 97709,
- 132066,
- 0
]
], - "durations": [
- [
- 0,
- 2690,
- 3927
], - [
- 2605,
- 0,
- 5126
], - [
- 4013,
- 5051,
- 0
]
]
}