use-geolocation-position

1.0.1 • Public • Published

use-geolocation-position

package version package downloads standard-readme compliant package license make a pull request

React hook for geolocation.getCurrentPosition and getCurrentPosition.watchPosition

Table of Contents

Usage

import React from 'react'

import { useCurrentPosition, useWatchPosition } from 'use-geolocation-position'

export default function App () {
  const currentPosition = useCurrentPosition({
    // Default config
    maximumAge: Infinity,
    timeout: 0,
    enableHighAccuracy: true
  })
  const watchedPosition = useWatchPosition({
    // Default config
    maximumAge: Infinity,
    timeout: 0,
    enableHighAccuracy: true
  })

  return (
    <div className='App'>
      <p>{JSON.stringify(currentPosition, null, 2)}</p>
      <p>{JSON.stringify(watchedPosition, null, 2)}</p>
    </div>
  )
}

Install

This project uses node and npm.

$ npm install use-geolocation-position
$ # OR
$ yarn add use-geolocation-position

Contribute

  1. Fork it and create your feature branch: git checkout -b my-new-feature
  2. Commit your changes: git commit -am "Add some feature"
  3. Push to the branch: git push origin my-new-feature
  4. Submit a pull request

License

MIT

Package Sidebar

Install

npm i use-geolocation-position

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

5.53 kB

Total Files

4

Last publish

Collaborators

  • tiaanduplessis