PhoneGap Android 地理定位。某些属性始终为空

发布于 2024-12-10 18:49:55 字数 1370 浏览 0 评论 0原文

作为一个例子,我实现了一个方法,它向我展示了所有的地理位置信息。

    function showLocation() {
    navigator.geolocation.getCurrentPosition(onGeoSuccess, onGeoError);
}

        function onGeoSuccess(position) {
    var element = document.getElementById('geolocation');
    element.innerHTML = 'Latitude: '           + position.coords.latitude              + '<br />' +
                        'Longitude: '          + position.coords.longitude             + '<br />' +
                        'Altitude: '           + position.coords.altitude              + '<br />' +
                        'Accuracy: '           + position.coords.accuracy              + '<br />' +
                        'Altitude Accuracy: '  + position.coords.altitudeAccuracy      + '<br />' +
                        'Heading: '            + position.coords.heading               + '<br />' +
                        'Speed: '              + position.coords.speed                 + '<br />' +
                        'Timestamp: '          + new Date(position.timestamp)          + '<br />';
}

所以我按下这个按钮绕着街区走了一圈:

<input type="submit" data-theme="d" name="login" id="login" value="Position" onclick="showLocation()"/>

但是,高度、航向和速度的属性始终显示为空。 海拔精度也显示为空,但phonegap文档说它不适用于android。那么为什么这不起作用呢? 预先感谢,丹尼尔

As an example I implemented a method wich shows me all the geolocation stuff.

    function showLocation() {
    navigator.geolocation.getCurrentPosition(onGeoSuccess, onGeoError);
}

        function onGeoSuccess(position) {
    var element = document.getElementById('geolocation');
    element.innerHTML = 'Latitude: '           + position.coords.latitude              + '<br />' +
                        'Longitude: '          + position.coords.longitude             + '<br />' +
                        'Altitude: '           + position.coords.altitude              + '<br />' +
                        'Accuracy: '           + position.coords.accuracy              + '<br />' +
                        'Altitude Accuracy: '  + position.coords.altitudeAccuracy      + '<br />' +
                        'Heading: '            + position.coords.heading               + '<br />' +
                        'Speed: '              + position.coords.speed                 + '<br />' +
                        'Timestamp: '          + new Date(position.timestamp)          + '<br />';
}

so I took a walk arround the block pressing this button:

<input type="submit" data-theme="d" name="login" id="login" value="Position" onclick="showLocation()"/>

However, the Attributes for Altitude, Heading and Speed always shows null.
Altitude Accuracy also shows null, but the phonegap docu says it´s not working with android. So why is this not working?
thanks in advance, Daniel

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

李不 2024-12-17 18:49:55

dev.w3.org/geo/api/spec-source.html#coordinates_interface

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

dev.w3.org/geo/api/spec-source.html#coordinates_interface

it might be device specific, as to whether or not those parameters are supported "If the implementation cannot provide {those variables you're having trouble with} information, the value of this attribute must be null."

清浅ˋ旧时光 2024-12-17 18:49:55

从我对phonegap 1.5 所做的测试中,我发现其中许多属性仅在我的设备处于运动状态时返回一个值。我确实得到了静止时的准确度数字(我想我的手机中有一个 GPS 传感器),它从几千米下降到不到 100 米。但是,我只能在设备移动时获得航向和速度。此外,航向是行进方向,它与手机的方向无关。

From the tests I have done with phonegap 1.5, I have found that many of these attributes only return a value if my device is in motion. I do get an accuracy number at rest (I think I have a gps sensor in my phone), it goes from a few thousand meters down to less than 100. However, I only get a heading and speed when the device is moving. Also the heading is the direction of travel, it is independent of the orientation of the phone.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文