MapQuest.js
L.mapquest.directions().dragRoute(options, callback)
A class that acts as an interface to the MapQuest Drag Route 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.dragRoute({
"mapState": {
"center": {
"lat": 40.47683477496205,
"lng": -76.46776167187544
},
"width": 400,
"height": 300,
"scale": 1733371
},
"locations": [
{
"linkId": 26982167,
"latLng": {
"lng": -77.793263,
"lat": 40.777703
},
"dragPoint": false
},
{
"latLng": {
"lng": -76.85228315623507,
"lat": 40.296919938790374
},
"dragPoint": true
},
{
"linkId": 37654138,
"latLng": {
"lng": -75.16562,
"lat": 39.951061
},
"dragPoint": false
}
]
}, dragRouteCallback);
function dragRouteCallback(error, response) {
console.log(response);
}
Response
js
{
"route": {
"hasTollRoad": false,
"computedWaypoints": [],
"fuelUsed": 0,
"shape": {
"maneuverIndexes": [],
"shapePoints": [
40.777702,
-77.793266,
40.794662,
-77.625228,
40.760421,
-77.614624,
40.732818,
-77.635719,
40.727794,
-77.604789,
40.66875,
-77.60427,
40.579151,
-77.551231,
40.611343,
-77.445587,
40.594306,
-77.37841,
40.538757,
-77.342369,
40.569873,
-77.243263,
40.564304,
-77.169738,
40.498077,
-77.126533,
40.471618,
-77.032493,
40.429916,
-77.010665,
40.382377,
-77.016738,
40.364086,
-76.928298,
40.301696,
-76.880767,
40.304107,
-76.830375,
40.213508,
-76.787384,
40.207733,
-76.568069,
40.227882,
-76.492874,
40.243461,
-76.154251,
40.208847,
-76.023696,
40.17218,
-75.979843,
40.176971,
-75.926872,
40.141578,
-75.806976,
40.099533,
-75.749961,
40.065311,
-75.65538,
40.090778,
-75.411567,
40.063911,
-75.328041,
40.071289,
-75.28289,
40.004798,
-75.196006,
39.982254,
-75.207763,
39.951061,
-75.165618
],
"legIndexes": [
0
]
},
"hasUnpaved": false,
"hasHighway": false,
"realTime": -1,
"distance": 81.571,
"time": 5022,
"locationSequence": [
0,
1,
2
],
"locations": [
{
"latLng": {
"lng": -77.793263,
"lat": 40.777703
},
"adminArea4": "",
"adminArea5Type": "City",
"adminArea4Type": "County",
"adminArea5": "",
"street": "",
"adminArea1": "",
"adminArea3": "",
"type": "s",
"displayLatLng": {
"lng": -77.793263,
"lat": 40.777703
},
"linkId": 26982167,
"postalCode": "",
"sideOfStreet": "N",
"dragPoint": false,
"adminArea1Type": "Country",
"geocodeQuality": "LATLNG",
"geocodeQualityCode": "XXXXX",
"adminArea3Type": "State"
},
{
"latLng": {
"lng": -76.853797,
"lat": 40.302349
},
"adminArea4": "",
"adminArea5Type": "City",
"adminArea4Type": "County",
"adminArea5": "",
"street": "US-322 EAST",
"adminArea1": "",
"adminArea3": "",
"type": "s",
"displayLatLng": {
"lng": -76.853797,
"lat": 40.302349
},
"linkId": 37005976,
"postalCode": "",
"sideOfStreet": "N",
"dragPoint": true,
"adminArea1Type": "Country",
"geocodeQuality": "LATLNG",
"geocodeQualityCode": "XXXXX",
"adminArea3Type": "State"
},
{
"latLng": {
"lng": -75.16562,
"lat": 39.951061
},
"adminArea4": "",
"adminArea5Type": "City",
"adminArea4Type": "County",
"adminArea5": "",
"street": "",
"adminArea1": "",
"adminArea3": "",
"type": "s",
"displayLatLng": {
"lng": -75.16562,
"lat": 39.951061
},
"linkId": 37654138,
"postalCode": "",
"sideOfStreet": "N",
"dragPoint": false,
"adminArea1Type": "Country",
"geocodeQuality": "LATLNG",
"geocodeQualityCode": "XXXXX",
"adminArea3Type": "State"
}
],
"hasSeasonalClosure": false,
"hasCountryCross": false,
"legs": [
{
"hasTollRoad": false,
"index": 0,
"roadGradeStrategy": [],
"hasHighway": false,
"hasUnpaved": false,
"distance": 81.571,
"time": 5022,
"origIndex": -1,
"hasSeasonalClosure": false,
"origNarrative": "",
"hasCountryCross": false,
"formattedTime": "01:23:42",
"destNarrative": "",
"destIndex": -1,
"maneuvers": [
{
"signs": [],
"index": 0,
"maneuverNotes": [],
"direction": 0,
"narrative": "",
"iconUrl": "https://content.mapquest.com/mqsite/turnsigns/icon-dirs-start_sm.gif",
"distance": 81.571,
"time": 5022,
"linkIds": [],
"streets": [],
"attributes": 0,
"transportMode": "AUTO",
"formattedTime": "01:23:42",
"directionName": "",
"mapUrl": "https://www.mapquestapi.com/staticmap/v5/getmap?key=KEY&type=map&size=225,160&pois=purple-1,40.777702,-77.793266,0,0|purple-2,39.951060999999996,-75.165618,0,0|¢er=40.3728615,-76.479442&zoom=3&rand=-974493818&session=null",
"startPoint": {
"lng": -77.793266,
"lat": 40.777702
},
"turnType": -1
}
],
"hasFerry": false
}
],
"formattedTime": "01:23:42",
"routeError": {
"message": "",
"errorCode": -400
},
"options": {
"mustAvoidLinkIds": [],
"drivingStyle": 2,
"countryBoundaryDisplay": true,
"generalize": -1,
"narrativeType": "text",
"locale": "en_US",
"avoidTimedConditions": false,
"destinationManeuverDisplay": true,
"enhancedNarrative": false,
"filterZoneFactor": -1,
"timeType": 0,
"maxWalkingDistance": -1,
"routeType": "FASTEST",
"transferPenalty": -1,
"stateBoundaryDisplay": true,
"walkingSpeed": -1,
"maxLinkId": 0,
"arteryWeights": [],
"tryAvoidLinkIds": [],
"unit": "M",
"routeNumber": 0,
"shapeFormat": "raw",
"maneuverPenalty": -1,
"useTraffic": false,
"returnLinkDirections": false,
"avoidTripIds": [],
"manmaps": "true",
"highwayEfficiency": 22,
"sideOfStreetDisplay": true,
"cyclingRoadFactor": 1,
"urbanAvoidFactor": -1
},
"hasFerry": false
},
"info": {
"copyright": {
"text": "© 2017 MapQuest, Inc.",
"imageUrl": "https://api.mqcdn.com/res/mqlogo.gif",
"imageAltText": "© 2017 MapQuest, Inc."
},
"statuscode": 0,
"messages": []
}
}