How do I data is returned for an array and not for the functions onSuccess
and onError
?
function onSuccess(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.watchPosition(onSuccess, onError, { timeout: 30000 });
Example of what I need:
geolocation = navigator.geolocation.watchPosition(null, null, { timeout: 30000 });
if(!geolocation.error)
alert(geolocation.coords.latitude);
Plugin: https://github.com/apache/cordova-plugin-geolocation