# UseDirections

What [`useDirections`](https://docs.mapcairn.com/api/map/useDirections-function.md) returns.

This is an interface exported by `@mapcairn/map`, checked against version 0.2.0.

## Signature

```ts
import type { UseDirections } from "@mapcairn/map";
 
interface UseDirections
```

## Properties

### addStop

```ts
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

```ts
readonly available: boolean;
```

Whether the host provides a routing service. Without one the tool is not offered.

### canAddStop

```ts
readonly canAddStop: boolean;
```

Whether another stop fits.

### cancel

```ts
readonly cancel: () => void;
```

Stops a request that is running.

### clear

```ts
readonly clear: () => void;
```

Removes every stop and the result, and stops a request that is running.

### mode

```ts
readonly mode: TravelMode;
```

How the next request travels. Changing it clears the result.

### moveStop

```ts
readonly moveStop: (id: string, direction: -1 | 1) => void;
```

Moves a stop one place earlier (`-1`) or later (`1`).

### removeStop

```ts
readonly removeStop: (id: string) => void;
```

Removes the stop with this id.

### requestArea

```ts
readonly requestArea: (minutes: number) => void;
```

Asks the service for the area reachable from the first stop within `minutes`.

### requestRoute

```ts
readonly requestRoute: () => void;
```

Asks the service for a route through the stops. Needs at least two.

### result

```ts
readonly result: DirectionsOutcome | null;
```

The route or area on the map, or null.

### retry

```ts
readonly retry: () => void;
```

Asks again for the request that failed.

### setMode

```ts
readonly setMode: (mode: TravelMode) => void;
```

Chooses how to travel. A different mode clears the result, which was for the old one.

### state

```ts
readonly state: DirectionsState;
```

Whether a request is idle, running, done or failed.

### stops

```ts
readonly stops: readonly DirectionStop[];
```

The stops, in order.

## See also

- [`LatLng`](https://docs.mapcairn.com/api/core/LatLng.md)
- [`TravelMode`](https://docs.mapcairn.com/api/core/TravelMode.md)
- [`DirectionsOutcome`](https://docs.mapcairn.com/api/map/DirectionsOutcome.md)
- [`DirectionsState`](https://docs.mapcairn.com/api/map/DirectionsState.md)
- [`DirectionStop`](https://docs.mapcairn.com/api/core/DirectionStop.md)

Source: [packages/map/src/tools/Directions/useDirections.ts:91](https://github.com/MapCairn/mapcairn/blob/main/packages/map/src/tools/Directions/useDirections.ts#L91)
