Skip to main content

UseMeasure

What useMeasure returns.

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

Signature​

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

interface UseMeasure

Properties​

addPoint​

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

Adds a vertex at the end.

clear​

readonly clear: () => void;

Removes every vertex.

mode​

readonly mode: MeasureMode;

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

movePoint​

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​

readonly points: readonly LatLng[];

The vertices, in the order they were added.

readout​

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​

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

Switches between distance and area, keeping the points.

total​

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​

readonly undo: () => void;

Removes the last vertex. Does nothing with no points.

See also​

Source: packages/map/src/tools/MeasureToolbar/useMeasure.ts:28