2017-08-09 82 views
0

我在iOS上遇到了問題,即從GPS中的phonegap/cordova獲取速度。無論是在我的車裏開車還是靜止不動,它都會返回NaN。navigator.geolocation.watchPosition返回NaN的速度

function speed_start() { 
     speed_timer_id = navigator.geolocation.watchPosition(speed_update_data, 
                speed_update_error, 
                { enableHighAccuracy: true }); 
} 

var speed_update_data = function(position) { 
     $("#speed-debug").html('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'); 
}; 

var speed_update_error = function(error) { 
     $("#speed-debug").html(error.message); 
} 

回答

0

這是一個硬件「問題」。似乎GPS沒有足夠的信號。