Instance Method


Retrieves directions and estimated travel time based on the specified start and end points.


Number route(DirectionsRequest request, function callback);



A DirectionsRequest object that specifies details for the directions you want to retrieve.


A callback function that receives the directions, returned asynchronously.

Return Value

A request ID, which you can pass to cancel to abort a pending request.


To get directions, provide a DirectionsRequest object when you call the route method.

Directions are returned asynchronously via a callback function. This callback function is invoked with two arguments, error and on failure and data on success.

error contains an error code and a text description of the error and data is a DirectionsResponse object with the following two properties:

  • request is the request object associated with this response.

  • routes contains an array of up to three Route objects returned by the server.

See Also

Getting Directions


The requested start and end points for a route, as well as the planned mode of transportation.


The directions and estimated travel time returned for a route.


Information about a route, including step-by-step instructions, distance, and estimated travel time.


A single route between a requested start and end point.