UseLocate
What useLocate returns.
This is an interface exported by @mapcairn/map, checked against version 0.2.0.
Signature
import type { UseLocate } from "@mapcairn/map";
interface UseLocate
Properties
cancel
readonly cancel: () => void;
Cancels a request in flight and returns to idle. Calling it after a
result or an error also returns to idle, which is how the app dismisses
the status message.
error
readonly error: LocationErrorKind | null;
Why the last request failed. Set only while state is error.
fix
readonly fix: LocationFix | null;
The latest fix. Set only while state is found.
locate
readonly locate: () => void;
Asks for the user's location. Call it only from a user action, such as a click on "Locate me": the browser may show a permission prompt. A second call cancels the first.
message
readonly message: string;
Visible status text for the app to show in a StatusMessage: empty when
idle, "Finding your location..." while locating, the accuracy when found
and what went wrong, with a next step, on an error. The text for an error
must stay on screen until the user dismisses it.
state
readonly state: LocateState;
Whether a request is idle, running, has found a fix or failed.