Geolocation.getCurrentPosition() - Web APIs | MDN
Thu Jan 06 2022 07:44:13 GMT+0000 (Coordinated Universal Time)
Saved by
@PIzmAR
#javascript
var options = {
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0
};
function success(pos) {
var crd = pos.coords;
console.log('Your current position is:');
console.log(`Latitude : ${crd.latitude}`);
console.log(`Longitude: ${crd.longitude}`);
console.log(`More or less ${crd.accuracy} meters.`);
}
function error(err) {
console.warn(`ERROR(${err.code}): ${err.message}`);
}
navigator.geolocation.getCurrentPosition(success, error, options);
content_copyCOPY
Get current latitude and longitude
https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition
Comments