I have a function triggered by button click that checks geolocation..it works fine on phones when geolocation is on, and when off, a message saying so displays, as expected. The problem occurs when first the phone's location service is turned off, the button is clicked(message pops up, as expected), then if the user turns location services back on while app is still open, and again clicks the button, still the same 'no location service' message pops up.
Is there a way to check if the phone's location service is turned on or off on each button click? Getting the same results on Android and IOS.
code:
$(document).ready(function () {
$('#smallScreenGeolocate').on('click', function(){
getCurrentLocation();
});
});
function getCurrentLocation () {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(addGeolocationMarker, locationError);
return true;
}
else {
alert("Browser doesn't support Geolocation. Visit http://caniuse.com to discover browser support for the Geolocation API.");
return false;
}
}