nidus-sync/html/static/js/location.js
Eli Ribble 9b1d75d47f
Rename htmlpage to html
Because it's going to get more tools.
2026-01-30 19:32:01 +00:00

23 lines
573 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
);
});
}