GPS Geolocation应用程序无法在Phonegap for Android中使用

Ahm*_*.A. 0 android geolocation cordova

我正在创建一个获取用户位置的应用程序.应用程序使用3G正常工作,问题来自我禁用3G并想要只使用GPS运行应用程序,应用程序甚至无法启动.

我有的代码:

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
    navigator.geolocation.getCurrentPosition(onSuccess, onError);
}

function onSuccess(position) {
    var element = document.getElementById('geolocation');
    element.innerHTML = 'Latitude: '           + position.coords.latitude              + '<br />' +
                        'Longitude: '          + position.coords.longitude             + '<br />' +
                        'Altitude: '           + position.coords.altitude              + '<br />' +
                        'Accuracy: '           + position.coords.accuracy              + '<br />' +
                        'Altitude Accuracy: '  + position.coords.altitudeAccuracy      + '<br />' +
                        'Heading: '            + position.coords.heading               + '<br />' +
                        'Speed: '              + position.coords.speed                 + '<br />' +
                        'Timestamp: '          + new Date(position.timestamp)          + '<br />';
}

function onError(error) {
    alert('code: '    + error.code    + '\n' +
          'message: ' + error.message + '\n');
} 
Run Code Online (Sandbox Code Playgroud)

Dan*_*ibe 8

地理定位并不意味着您将使用GPS.默认情况下,您将使用网络位置.您必须启用高精度!