0
我是手機新手。我正在創建一個獲取設備位置的應用程序...我已經使用galaxy galaxy tab和htc進行了測試,但是沒有做任何事情...我嘗試獲取設備的速度,並將其顯示在在屏幕上的div。這是我的代碼:phonegap應用程序不起作用
地理位置:
// 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');
}
我在紋波,Chrome瀏覽器的擴展測試,並能正常工作,改變速度的值,並能正常工作......但用設備,我不知道爲什麼不。 爲什麼可以? 的問候,丹尼爾
我已閱讀,也許是需要添加{enableHighAccuracy:真正}在VAR選項...但我不明白這一點...
它在模擬器中工作嗎? – Aamirkhan
是的,在鉻的波紋擴展 – Daniel