MapQuest.js
L.mapquest.directions().routeMatrix(options, callback)
A class that acts as an interface to the MapQuest Route Matrix API. The results of the API call will be passed in the error-first callback style.
Syntax
js
L.mapquest.key = 'KEY';
var directions = L.mapquest.directions();
directions.routeMatrix({
'locations': [
'Denver, CO',
'Westminster, CO',
'Boulder, CO'
],
'options': {
'allToAll': true
}
}, routeMatrixCallback);
function routeMatrixCallback(error, response) {
console.log(response);
}
Response
js
{
"allToAll": true,
"distance": [
[
0,
13.052,
29.369
],
[
11.67,
0,
17.06
],
[
28.441,
17.783,
0
]
],
"time": [
[
0,
1037,
2150
],
[
1068,
0,
1253
],
[
2119,
1242,
0
]
],
"locations": [
{
"latLng": {
"lng": -104.984853,
"lat": 39.738453
},
"adminArea4": "Denver County",
"adminArea5Type": "City",
"adminArea4Type": "County",
"adminArea5": "Denver",
"street": "",
"adminArea1": "US",
"adminArea3": "CO",
"type": "s",
"displayLatLng": {
"lng": -104.984853,
"lat": 39.738453
},
"linkId": 282041090,
"postalCode": "",
"sideOfStreet": "N",
"dragPoint": false,
"adminArea1Type": "Country",
"geocodeQuality": "CITY",
"geocodeQualityCode": "A5XAX",
"adminArea3Type": "State"
},
{
"latLng": {
"lng": -105.050335,
"lat": 39.863462
},
"adminArea4": "City and County of Broomfield",
"adminArea5Type": "City",
"adminArea4Type": "County",
"adminArea5": "Westminster",
"street": "",
"adminArea1": "US",
"adminArea3": "CO",
"type": "s",
"displayLatLng": {
"lng": -105.050335,
"lat": 39.863462
},
"linkId": 282040216,
"postalCode": "",
"sideOfStreet": "N",
"dragPoint": false,
"adminArea1Type": "Country",
"geocodeQuality": "CITY",
"geocodeQualityCode": "A5XAX",
"adminArea3Type": "State"
},
{
"latLng": {
"lng": -105.27927,
"lat": 40.015831
},
"adminArea4": "Boulder County",
"adminArea5Type": "City",
"adminArea4Type": "County",
"adminArea5": "Boulder",
"street": "",
"adminArea1": "US",
"adminArea3": "CO",
"type": "s",
"displayLatLng": {
"lng": -105.27927,
"lat": 40.015831
},
"linkId": 282039983,
"postalCode": "",
"sideOfStreet": "N",
"dragPoint": false,
"adminArea1Type": "Country",
"geocodeQuality": "CITY",
"geocodeQualityCode": "A5XAX",
"adminArea3Type": "State"
}
],
"manyToOne": false,
"info": {
"copyright": {
"text": "© 2017 MapQuest, Inc.",
"imageUrl": "https://api.mqcdn.com/res/mqlogo.gif",
"imageAltText": "© 2017 MapQuest, Inc."
},
"statuscode": 0,
"messages": []
}
}