I'd like to get the user_longitude and user_latitude values outside of the function, but I don't really understand how to do that. Why? This is the first time I'm dealing with a function that is a bit strange for me, because I understand that the success function is an argument in navigator.geolocation.getCurrentPosition(success) but at the same time it has an additional pos argument, which is later used in crd, so my additional question is:
What is the pos argument?
function success(pos) {
const 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.`);
const user_latitude = crd.latitude
const user_longitude = crd.longitude
return user_longitude, user_latitude
}
navigator.geolocation.getCurrentPosition(success)