Platform: iOS6/OSx Lion.
I'm trying to puzzle out the way Phonegap/Cordova work with navigator.geolocation.watchPosition
.
The docs says that the option "maximumAge
" is the one that ask the system for retrieve the position.
So with these options:
{ maximumAge: 3000, timeout: 5000, enableHighAccuracy: true }
I espect the position request will be fired every 3 seconds?
And no matter what maximumAge
I put the success is fired every 1 second...
Anyone can explain please?
Thanks Bye
Rob
Let us discuss some key differences between PhoneGap vs Cordova in the following points: 1. PhoneGap is Adobe Systems ‘ cross-platform mobile development system to build mobile platform-independent applications. It is using standard web technologies such as JavaScript, HTML, and CSS to connect web apps to mobile devices. 2.
PhoneGap originally started as an open-source project by Nitobi Software in 2008. Nitobi Software was acquired by Adobe in 2011 and shortly after donated PhoneGap to the Apache Software Foundation as Cordova.
Apache Cordova, which was a core tool of Adobe PhoneGap and PhoneGap Build for the past nine years, will continue to thrive as long as the health of the community remains strong and contributions are made. If you use, have used, or looking to start using Cordova, also consider contributing and taking part in this awesome community to help it grow.
The plugin is available only in IntelliJ IDEA Ultimate. PhoneGap and Apache Cordova are frameworks for developing mobile application with single HTML, CSS, and JavaScript/TypeScript code base and targeting various mobile platforms, including Android.
I am currently working around this issue by using getCurrentPosition
with a setInterval
. I'm not sure what the consequences may be, but this seems to give me the most control and appears to be the most consistent method across platforms.
// call this once
setupWatch(3000);
// sets up the interval at the specified frequency
function setupWatch(freq) {
// global var here so it can be cleared on logout (or whenever).
activeWatch = setInterval(watchLocation, freq);
}
// this is what gets called on the interval.
function watchLocation() {
var gcp = navigator.geolocation.getCurrentPosition(
updateUserLoc, onLocationError, {
enableHighAccuracy: true
});
// console.log(gcp);
}
// do something with the results
function updateUserLoc(position) {
var location = {
lat : position.coords.latitude,
lng : position.coords.longitude
};
console.log(location.lat);
console.log(location.lng);
}
// stop watching
function logout() {
clearInterval(activeWatch);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With