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