API Docs for: 2.2
Show:

MQ.Routing.Directions Class

Extends L.Class

NOTE: This is typically not instantiated directly, instead use MQ.routing.directions.

The MQ.Routing.Directions class provides access to MapQuest's directions services (http://www.mapquestapi.com/directions).

Constructor

MQ.Routing.Directions

(
  • options
)

Parameters:

Methods

_checkShapeFormat

(
  • request
)
private

Adds the option to use compressed shapepoints if no shapeFormat option is supplied

Parameters:

_onResult

(
  • response
  • requestTime
  • successType
)
private

Parameters:

_trimLocations

(
  • locations
)
Array private

Attempts to trim down the data passed back to the server by changing the locations to only have a linkId, lat/lng and type. If no link id is present, we dont try to trim, it will send back the entire route. This is mostly to help url length the problems of IE.

Parameters:

Returns <Array>

trimmed array of locations for proper url building

callback

(
  • routeRequest
)
Object

Derivative of the route request which takes identical parameters but also takes map state fields of width, height and scale.

For a FULL list of route options, please visit http://www.mapquestapi.com/directions

Parameters:

Returns <Object>

results

decompress

(
  • results
)
Object static

This function gets called prior to executing the callback on any of the routing functions. If routeRequest.options.shapeFormat=='cmp' (compressed) then we need to decompress it prior to letting the route module do its work. You do not need to specify the options.shapeFormat in your request, it will always default to cmp but you can use the raw format if needed by setting routeRequest.options.shapeFormat='raw' as an option to the routing functions. This function does require an instantiated RouteIO object to use.

NOTE: the algorithm used was adapted from http://soulsolutions.com.au/Default.aspx?tabid=96

Parameters:

Returns <Object>

results with decompressed lat/lngs or the original results if shapeType!='cmp'

initialize

(
  • options
)

Parameters:

optimizedRoute

(
  • routeRequest
)
Object

Execute an optimized route with the given routeRequest.

For a FULL list of route options, please visit http://www.mapquestapi.com/directions

Parameters:

Returns <Object>

results

route

(
  • routeRequest
)
Object

Execute route with the given routeRequest. Will make an alternateroutes call if maxRoutes > 1 && locations.length == 2

For a FULL list of route options, please visit http://www.mapquestapi.com/directions

Parameters:

Returns <Object>

results

routeMatrix

(
  • routeRequest
)

Route matrix. This function will only return data there are no map interactions avalable for route matrices.

For a FULL list of route options, please visit http://www.mapquestapi.com/directions

Parameters:

routeShape

(
  • shapeRequest
)
Object

Initiates a routeShape server call

For a FULL list of route options, please visit http://www.mapquestapi.com/directions

Parameters:

Returns <Object>

results

Events

altsuccess

Fired when an alternate route's data has been retrieved from the server and shapePoints have been decompressed. See http://www.mapquestapi.com/directions/#response for payload description

altsuccess:[route|optimized|drag|matrix]

Fired when an alternative route's data has been retrieved from the server and shapePoints have been decompressed. See http://www.mapquestapi.com/directions/#response for payload description

error

Event Payload:

success

Fired when route data has been retrieved from the server and shapePoints have been decompressed. (For all types of directions calls including routeShape calls, typically you will want to listen to the 'success:' event which matches the type of request you initiated.) See http://www.mapquestapi.com/directions/#response for payload description

success:[route|optimized|drag|matrix]

Fired when route data has been retrieved from the server and shapePoints have been decompressed. See http://www.mapquestapi.com/directions/#response for payload description

success:altRoutes

Fired when all alternative routes' data has been retrieved from the server and shapePoints have been decompressed. See http://www.mapquestapi.com/directions/#response for payload description

success:routeShape