UseDirections
What useDirections returns.
This is an interface exported by @mapcairn/map, checked against version 0.2.0.
Signature
import type { UseDirections } from "@mapcairn/map";
interface UseDirections
Properties
addStop
readonly addStop: (position: LatLng, label?: string) => void;
Adds a stop at the end, naming it when label is given. Says so when the list is full.
available
readonly available: boolean;
Whether the host provides a routing service. Without one the tool is not offered.
canAddStop
readonly canAddStop: boolean;
Whether another stop fits.
cancel
readonly cancel: () => void;
Stops a request that is running.
clear
readonly clear: () => void;
Removes every stop and the result, and stops a request that is running.
mode
readonly mode: TravelMode;
How the next request travels. Changing it clears the result.
moveStop
readonly moveStop: (id: string, direction: -1 | 1) => void;
Moves a stop one place earlier (-1) or later (1).
removeStop
readonly removeStop: (id: string) => void;
Removes the stop with this id.
requestArea
readonly requestArea: (minutes: number) => void;
Asks the service for the area reachable from the first stop within minutes.
requestRoute
readonly requestRoute: () => void;
Asks the service for a route through the stops. Needs at least two.
result
readonly result: DirectionsOutcome | null;
The route or area on the map, or null.
retry
readonly retry: () => void;
Asks again for the request that failed.
setMode
readonly setMode: (mode: TravelMode) => void;
Chooses how to travel. A different mode clears the result, which was for the old one.
state
readonly state: DirectionsState;
Whether a request is idle, running, done or failed.
stops
readonly stops: readonly DirectionStop[];
The stops, in order.
See also
Source: packages/map/src/tools/Directions/useDirections.ts:91