【问题标题】:Cordova Geolocation --- Altitude Not Work科尔多瓦地理定位 --- 海拔不工作
【发布时间】:2015-07-30 09:47:18
【问题描述】:

我正在使用该插件进行科尔多瓦的地理定位,除海拔高度外,一切正常。 是我的问题还是不可能有这个值? 这是插件代码和我的:

var onSuccess = function (posizione) {
    alert ('Latitudine:' + position.coords.latitude + '\ n' +
          'Longitude:' + position.coords.longitude + '\ n' +
          'Altitudine:' + position.coords.altitude + '\ n' +
          'Precisione:' + position.coords.accuracy + '\ n' +
          'Altitude Precisione:' + position.coords.altitudeAccuracy + '\ n' +
          'Intestazione:' + position.coords.heading + '\ n' +
          'Speed:' + position.coords.speed + '\ n' +
          'Timestamp:' + position.timestamp + '\ n');
};

// OnError Callback riceve un oggetto PositionError
//
Funzione onError (errore) {
    alert ('codice:' + error.code + '\ n' +
          'Messaggio:' + Error.message + '\ n');
}

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

我再说一遍,它不工作。

【问题讨论】:

    标签: javascript android cordova geolocation altitude


    【解决方案1】:

    如果从卫星接收到数据,则代码有效。在你输入减号之前,我建议检查卫星的可用性以及代码如何处理来自卫星的数据。 我的代码:

    app.positionWatchID = navigator.geolocation.watchPosition(
                function(result){
                    app.alt = Math.round(result.coords.altitude) || app.base_alt;
                    app.setAltimeterValue(app.alt);
                },
                function(){},
                {
                    timeout: 30000,
                    maximumAge: 3000,
                    enableHighAccuracy: true
                }
            );
    

    当卫星可见时工作正常,如果卫星不可见,我收到 null。 getCurrentPosition 也有效

    【讨论】:

    • 可能收不到值,但这不是解决办法。它不是一个有效的答案。
    猜你喜欢
    • 1970-01-01
    • 2018-07-20
    • 1970-01-01
    • 1970-01-01
    • 2015-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多