I am developing a phonegap application focused on the iOS platform. I want to capture the geographic location of the user. I use below code for this, which worked fine for a while and suddenly stopped working
<script type="text/javascript">
var onSuccess = function(position) {
alert('Latitude: ' + position.coords.latitude + '\n' +
'Longitude: ' + position.coords.longitude + '\n' +
'Altitude: ' + position.coords.altitude + '\n' +
'Accuracy: ' + position.coords.accuracy + '\n' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' +
'Heading: ' + position.coords.heading + '\n' +
'Speed: ' + position.coords.speed + '\n' +
'Timestamp: ' + position.timestamp + '\n');
};
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
navigator.geolocation.getCurrentPosition(onSuccess, onError);
</script>
Above, the code returned latitude and longitude by about 7 times, but after that the callback function is not called, and sometimes it shows that the user has disabled the pop-up in the browser.
source
share