I was wondering if it is possible to use Javascript Geolocation to change a variable?
As in- if I am in California, then my Javascript geolocation code will return true. But if I am somewhere else it will return false.
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude + "<br>Longitude: " + position.coords.longitude;
}
Is there any way to do this?