【发布时间】:2017-08-09 06:41:33
【问题描述】:
我在从 iOS 上 phonegap/cordova 中的 GPS 获取速度时遇到问题。无论我是开着车还是站着不动,它都会返回 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);
}
【问题讨论】:
标签: javascript ios cordova geolocation gps