Skip to main content

useLocation

Source: hooks/useLocation.ts (102 lines) The useLocation hook manages GPS position tracking with a three-branch permission handling strategy that adapts to the user’s current permission state.

Permission State Machine

The hook handles three distinct permission states:

Location Fetch

When permission is granted, the hook fetches the current position with high accuracy:

Callback Pattern

The requestLocation function accepts an optional onSuccess callback, allowing callers to run additional logic (like animating the map camera) immediately after coordinates are available:

Return Value


LocationCoords Type