简体   繁体   中英

Cordova Geolocation — Altitude Not Work

I am using the plugin for geolocation of cordova and it all works , except the altitude . is my problem or it is not possible to have this value ? This is the plugin code and my:

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});

I repeat , it does not work just that.

The code works if the data received from the satellite. Before you put minus I recommend to check the availability of satellites and how the code works with data from satellites. My code:

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
            }
        );

Work fine when satellites is visible and i recieved null if satellites is invisible. getCurrentPosition works also

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM