Overview
ThegetGeolocationData() utility function retrieves the user’s current geolocation coordinates.
Import
Usage
Return Value
number | null
User’s latitude coordinate
number | null
User’s longitude coordinate
string | null
Error message if geolocation access failed or was denied
boolean
Whether geolocation is currently being fetched
Example
Error Handling
The function handles various geolocation scenarios:- Permission denied: User denied location access
- Timeout: Location request timed out
- Not available: Geolocation API not available
- Position unavailable: Could not determine position