nidus-sync/static/js/location.js
Eli Ribble 31947c848a
Move static outside HTML. Start work on TypeScript bundle
It's not strictly HTML, so that's just correct.

This is just worth doing while building the new TypeScript bundle
2026-03-21 03:06:59 +00:00

23 lines
575 B
JavaScript

function getGeolocation(options) {
return new Promise((resolve, reject) => {
// Check if geolocation is supported by the browser
if (!navigator.geolocation) {
reject(new Error("Geolocation is not supported by your browser"));
return;
}
// Default options if none provided
const geolocationOptions = options || {
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0,
};
// Call the geolocation API
navigator.geolocation.getCurrentPosition(
(position) => resolve(position),
(error) => reject(error),
geolocationOptions,
);
});
}