Skip to content

Latest commit

 

History

History
44 lines (35 loc) · 941 Bytes

doc.md

File metadata and controls

44 lines (35 loc) · 941 Bytes

useGeolocation

Vue hook that tracks geo location state of user's device.

This hook accepts position options.

Browser environment is required

Usage

import { createComponent } from '@vue/composition-api'
import { useGeolocation } from 'vuses'

const Demo = createComponent({
  setup() {
    const geo = useGeolocation()
    return { geo }
  },
  render() {
    const { geo } = this
    return <pre>geo: {JSON.stringify(geo, null, 2)}</pre>
  }
})

Reference

interface GeoLocationSensorState {
  loading: boolean
  accuracy: number | null
  altitude: number | null
  altitudeAccuracy: number | null
  heading: number | null
  latitude: number | null
  longitude: number | null
  speed: number | null
  timestamp: number | null
  error?: Error | PositionError
}

function useGeolocation(options?: PositionOptions): GeoLocationSensorState