首页 文章

Speed Coordinate在GeoLocation PhoneGap中显示空值

提问于
浏览
0

我正在创建Android应用程序获取Lat Lng并检查用户的速度我正在使用PhoneGap GeoLocation Api但我只获得经度和纬度但是在Altitude和Speed它显示null这里是我从PhoneGap网站获得的JavaScript

<script type="text/javascript">
    document.addEventListener("deviceready", onDeviceReady, false);

    // PhoneGap is ready
    //
    function onDeviceReady() {
        var options = { enableHighAccuracy: true };
        navigator.geolocation.getCurrentPosition(onSuccess, onError);
    }

    // onSuccess Geolocation
    //
    function onSuccess(position) {
        var element = document.getElementById('time');
        element.innerHTML = 'Latitude: '           + position.coords.latitude              + '
' + 'Longitude: ' + position.coords.longitude + '
' + 'Altitude: ' + position.coords.altitude + '
' + 'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '
' + 'Speed: ' + position.coords.speed + '
' + 'Timestamp: ' + new Date(position.timestamp) + '
'; setTimeout('loop();',100); } // onError Callback receives a PositionError object // function onError(error) { alert('code: ' + error.code + '\n' + 'message: ' + error.message + '\n'); } function loop(){ navigator.geolocation.getCurrentPosition(onSuccess, onError); } </script>

我在Android Mobile以及模拟器中检查这个结果两个地方都是null Html部分是

<body>
<p id="time">Finding geolocation...</p>

1 回答

  • 0

    Source

    它可能是特定于设备的,是否支持这些参数“如果实现无法提供{那些你遇到问题的变量}信息,则该属性的值必须为null . ”

相关问题