【发布时间】:2014-02-16 14:52:50
【问题描述】:
我使用了文档中的示例。我收到带有坐标的警报,但是如果我阻止 GPS 或将其关闭,则什么也不会发生。如果我更换 navigator.geolocation.getCurrentPosition(onSuccess, onError); 和 navigator.geolocation.getCurrentPosition(onError); 显示警报。
谁有想法?
这是从文档中得知的代码
navigator.geolocation.getCurrentPosition(onSuccess, onError);
//AKTUELLE POSITION ERMITTELN
var onSuccess = function(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');
}
//Error Callback für eigene Position
function onError(error)
{
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
【问题讨论】:
-
你如何使用你的回调?
-
我稍后会将代码作为编辑发布在我的第一篇文章中
-
禁用位置时不会触发任何回调吗?
-
似乎不是这样。我没有收到警报,eclipse 中没有错误
标签: cordova geolocation