Contents

route(request, callback)

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

Declaration

route(
        request: DirectionsRequest,
        callback: (error: Error | null, result?: DirectionsResponse) => void,
    ): number;

Parameters

  • request:

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

  • callback:

    A callback function that receives the directions, returned asynchronously.

Return Value

A request ID, which you can pass to cancel(id) to cancel a pending request.

Discussion

Call the route(request, callback) method to get directions.

MapKit JS returns directions asynchronously via a callback function. This callback function is invoked with two arguments, error on failure and data on success.

error contains an error code and a text description of the error. 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