Skip to main content

useLocate

Finds the user's location through the services' LocationProvider, one request at a time. Each request has its own AbortController, aborted by a newer request, by cancel and on unmount; a cancelled request never changes state or announces anything.

This is a function exported by @mapcairn/map, checked against version 0.2.0.

Signature​

import { useLocate } from "@mapcairn/map";

function useLocate(units: UnitSystem, input?: UseLocateOptions): UseLocate;

Description​

The outcome is announced through the app-wide announcer, and message carries the same wording for the visible status.

Parameters​

  • units (UnitSystem)
  • { timeoutMs, announceErrors }?
  • input? (UseLocateOptions)

Returns​

UseLocate

Remarks​

Announcing and showing the same error means a screen reader may hear it twice if the app puts message in an alert StatusMessage; pass announceErrors: false in that case.

See also​

Source: packages/map/src/tools/locate/useLocate.ts:77