【问题标题】:BlackBerry Widget application - GPS location is always 0,0BlackBerry Widget 应用程序 - GPS 位置始终为 0,0
【发布时间】:2010-10-21 15:32:26
【问题描述】:

我正在尝试在黑莓上的小部件应用程序中获取 GPS 位置,但 API 始终返回 0,0 的纬度和经度。

模拟器:storm 2 (9550)/bold(9700) 和操作系统:5.0/5.0

IDE:Eclipse

html页面代码如下:

var modeCellsite   = 0;
var modeAssisted   = 1;
var modeAutonomous = 2;

function locationChanged()
{

    alert("Lat " + blackberry.location.latitude +
          " Lon " + blackberry.location.longitude +
          " Time " + blackberry.location.timestamp );
    return true;
}

if ( window.blackberry && blackberry.location.GPSSupported )
{
    var isUpdated = false;
    var theCount = 0;
    alert("Location tracking is supported");
    blackberry.location.onLocationUpdate("locationChanged()");
    blackberry.location.setAidMode(modeAutonomous);
    while ( theCount++ < 10 && !isUpdated )
        isUpdated = blackberry.location.refreshLocation();
}
else
{
    document.write("Location tracking is not supported");
}

【问题讨论】:

  • 我也有同样的问题,只是 js 略有不同但精神上很相似。

标签: blackberry blackberry-widgets


【解决方案1】:

在运行您的小部件之前,请确保您在 SIM 中打开了 GPS。

For Example in the simulator goto:
    Simulate -> GPS Location...
    Under Route Click "add"
    Choice Random Route Generator
       Number of Legs 1000
       Travel Time 600
       click OK
    Click Play arrow

【讨论】:

  • 这对我来说没有任何改变......我认为设置位置应该像在一条巨大的路径上发送它一样有效。
  • @Nilloc 我只是指出你应该确保打开 sim 的 GPS,否则你会得到 0,0(默认位置)。使用“巨大路径”的原因是您的用户永远不会静止不动,因此您应该测试路径而不是单个位置。我会说在 Java 中需要几秒钟才能获得更新的位置,所以我认为在紧密循环中调用 refreshlocation() 不会有太大的作用。我相信我看到的示例表明它在 locationChanged() 处理程序中被一次又一次地调用。
猜你喜欢
  • 1970-01-01
  • 2020-03-24
  • 1970-01-01
  • 2017-09-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多