I'm newbie with phonegap. I'm creating an app which gets the location of the device...I have tested with samsung galaxy tab and htc, but doesn't do anything...I try to get the speed of the device, and display it in a div in screen. This is my code:
GEOLOCATION:
// Phonegap loads
document.addEventListener("deviceready", onDeviceReady, false);
var watchIDgeolocation = null;
var watchIDaccelerometer = null;
// PhoneGap has loaded
function onDeviceReady() {
var options = { frequency: 1000 }; // I want obtain data each 1 s
watchIDgeolocation = navigator.geolocation.watchPosition(onSuccessGeolocation, onErrorGeolocation, options);
startWatch();
}
// Success
var onSuccessGeolocation = function(position) {
// These are functions that displays data in screen
cambioMarchas(position.coords.speed);
excesoVelocidad(position.coords.speed);
paradaProlongada(position.coords.speed);
aceleracionBrusca(position.coords.speed);
deceleracionBrusca(position.coords.speed);
accidenteDeTrafico(position.coords.speed);
// ERROR
function onErrorGeolocation(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
I have tested in Ripple, the extension of Chrome, and it works fine, changing values of the speed, and it works fine...but with device, I don't know why not. Why can be? Regards, Daniel
I have read that maybe is needed to add { enableHighAccuracy: true } in var options...but I don't understand this...