Skip to content
0

katanakit-js / useGetGeolocation

Function: useGetGeolocation() ​

ts
function useGetGeolocation(options?): Promise<
  | {
  accuracy: number;
  lat: number;
  lng: number;
}
| null>;

Defined in: src/infrastructure/sensors/sensors.service.ts:115

Gets the device's current geographic position once.

Parameters ​

ParameterTypeDescription
options?PositionOptionsOptional PositionOptions to override defaults.

Returns ​

Promise< | { accuracy: number; lat: number; lng: number; } | null>

A GeoPosition object or null on error / unavailability.

Example ​

ts
const pos = await useGetGeolocation({ enableHighAccuracy: true });
if (pos) console.log(`${pos.lat}, ${pos.lng}`);

Released under the MIT License.