地理位置不适用于BlackBerry

时间:2012-06-13 12:53:34

标签: blackberry cordova geolocation

我开发了一个使用phonegap检索地理位置的应用程序。

function getLoc() {
    navigator.geolocation.getCurrentPosition(onSuccess, onError, { enableHighAccuracy: true });
}

// onSuccess Geolocation
function onSuccess(position) {
    var locInfo = new Object();

    locInfo.Latitude = position.coords.latitude;
    locInfo.Longitude = position.coords.longitude;
    locInfo.Altitude = position.coords.altitude;
    locInfo.Accuracy = position.coords.accuracy;
    locInfo.AltitudeAccuracy = position.coords.altitudeAccuracy;
    locInfo.Heading = position.coords.heading;
    locInfo.Speed = position.coords.speed;

    alert(locInfo.Latitude + "   " + locInfo.Longitude);
}

// onError Callback receives a PositionError object
function onError(error) {
    alert('code: '    + error.code    + '\n' +
          'message: ' + error.message + '\n');
}

上面的代码在Android,iPhone和BlackBerry Simulator中运行正常,但在BlackBerry设备中却没有。我正在使用BlackBerry Torch进行测试。

可能是什么问题。请回复。

谢谢:)

1 个答案:

答案 0 :(得分:0)

尝试为getCurrentPosition设置超时。