Utilizing the getCurrentPosition
function from the navigator.geolocation
object has been seamless for me. However, I've noticed a hiccup when the user selects "this time not." In this case, I am unable to enter the error function. Below is my code snippet:
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition, getLocationIp);
} else {
console.log("Geolocation is not supported by this browser.");
}
};
function showPosition(position) {
console.log("Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude);
cargarArticulosInicio(position.coords.latitude, position.coords.longitude);
}
function getLocationIp() {
//Function to get location from IP
}