# UseMeasure

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

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

## Signature

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

## Properties

### addPoint

```ts
readonly addPoint: (point: LatLng) => void;
```

Adds a vertex at the end.

### clear

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

Removes every vertex.

### mode

```ts
readonly mode: MeasureMode;
```

Whether the points make an open line (`distance`) or a closed area (`area`).

### movePoint

```ts
readonly movePoint: (index: number, point: LatLng) => void;
```

Moves the vertex at `index`, for example while it is dragged. Out-of-range indexes are ignored.

### points

```ts
readonly points: readonly LatLng[];
```

The vertices, in the order they were added.

### readout

```ts
readonly readout: string;
```

The total as text in the chosen units, for example "1.25 km". "0 m" or "0 m²" until there are enough points.

### setMode

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

Switches between distance and area, keeping the points.

### total

```ts
readonly total: number | null;
```

The total in metres (`distance`) or square metres (`area`), measured
along the geodesic. `null` until there are enough points: two for a
distance, three for an area.

### undo

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

Removes the last vertex. Does nothing with no points.

## See also

- [`LatLng`](https://docs.mapcairn.com/api/core/LatLng.md)
- [`MeasureMode`](https://docs.mapcairn.com/api/map/MeasureMode.md)

Source: [packages/map/src/tools/MeasureToolbar/useMeasure.ts:28](https://github.com/MapCairn/mapcairn/blob/main/packages/map/src/tools/MeasureToolbar/useMeasure.ts#L28)
