@clurts/use-location
v1.0.3
Published
custom react hook to use the geolocation api
Downloads
15
Readme
use-location
Installation
To install using npm:
npm i @clurts/use-location
To install using yarn:
yarn add @clurts/use-location
Usage
Import the useLocation hook:
import useLocation from "@clurts/use-location"
In your component use as follows:
const [isLocating, position, error] = useLocation()
Api
isLocating: boolean - indicates wehter or not your postion is being retrieved currently.
position: object - containing geolocation information
Properties on the position object: | Property | Description | | --- | ----------- | | lat | Returns the current position latitude | | long | Returns the current position longitude |
error: string - error messages if access to location data is blocked or geolocation is not supported by the browser.