# UseLocate

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

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

## Signature

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

## Properties

### cancel

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

```ts
readonly error: LocationErrorKind | null;
```

Why the last request failed. Set only while `state` is `error`.

### fix

```ts
readonly fix: LocationFix | null;
```

The latest fix. Set only while `state` is `found`.

### locate

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

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

```ts
readonly state: LocateState;
```

Whether a request is idle, running, has found a fix or failed.

## See also

- [`LocationErrorKind`](https://docs.mapcairn.com/api/core/LocationErrorKind.md)
- [`LocationFix`](https://docs.mapcairn.com/api/core/LocationFix.md)
- [`LocateState`](https://docs.mapcairn.com/api/map/LocateState.md)

Source: [packages/map/src/tools/locate/useLocate.ts:37](https://github.com/MapCairn/mapcairn/blob/main/packages/map/src/tools/locate/useLocate.ts#L37)
