963 markdown files reformatted with the repository's pinned prettier so pnpm format:check covers the folded tree like every other repo file. The formatter's embedded-language pass also normalized code fences (TS semicolons, closed HTML tags in examples, lowercased CSS hex colors, one renumbered list that skipped an index). Alphanumeric token deltas vs the fold commit were audited file-by-file; all are formatter-equivalent markup normalizations plus the four sanitized skills.
3.2 KiB
3.2 KiB
category
| category |
|---|
| Sensors |
useGeolocation
Reactive Geolocation API. It allows the user to provide their location to web applications if they so desire. For privacy reasons, the user is asked for permission to report location information.
Usage
import { useGeolocation } from '@vueuse/core';
const { coords, locatedAt, error, resume, pause } = useGeolocation();
| State | Type | Description |
|---|---|---|
| coords | Coordinates |
information about the position retrieved like the latitude and longitude |
| locatedAt | Date |
The time of the last geolocation call |
| error | string |
An error message in case geolocation API fails. |
| resume | function |
Control function to resume updating geolocation |
| pause | function |
Control function to pause updating geolocation |
Config
useGeolocation function takes PositionOptions object as an optional parameter.
Component Usage
<template>
<UseGeolocation v-slot="{ coords: { latitude, longitude } }">
Latitude: {{ latitude }} Longitude: {{ longitude }}
</UseGeolocation>
</template>
Type Declarations
export interface UseGeolocationOptions extends Partial<PositionOptions>, ConfigurableNavigator {
immediate?: boolean;
}
/**
* Reactive Geolocation API.
*
* @see https://vueuse.org/useGeolocation
* @param options
*/
export declare function useGeolocation(options?: UseGeolocationOptions): {
isSupported: ComputedRef<boolean>;
coords: Ref<
{
readonly accuracy: number;
readonly altitude: number | null;
readonly altitudeAccuracy: number | null;
readonly heading: number | null;
readonly latitude: number;
readonly longitude: number;
readonly speed: number | null;
},
| Omit<GeolocationCoordinates, 'toJSON'>
| {
readonly accuracy: number;
readonly altitude: number | null;
readonly altitudeAccuracy: number | null;
readonly heading: number | null;
readonly latitude: number;
readonly longitude: number;
readonly speed: number | null;
}
>;
locatedAt: ShallowRef<number | null, number | null>;
error: ShallowRef<GeolocationPositionError | null, GeolocationPositionError | null>;
resume: () => void;
pause: () => void;
};
export type UseGeolocationReturn = ReturnType<typeof useGeolocation>;