BlackBerry Widget应用程序-GPS位置始终为0,0
我试图在blackberry上的小部件应用程序中获取GPS位置,但API总是返回0,0的纬度和经度 模拟器:风暴2(9550)/黑体(9700)和操作系统:5.0/5.0 IDE:Eclipse html页面代码如下所示:BlackBerry Widget应用程序-GPS位置始终为0,0,blackberry,blackberry-widgets,Blackberry,Blackberry Widgets,我试图在blackberry上的小部件应用程序中获取GPS位置,但API总是返回0,0的纬度和经度 模拟器:风暴2(9550)/黑体(9700)和操作系统:5.0/5.0 IDE:Eclipse html页面代码如下所示: var modeCellsite = 0; var modeAssisted = 1; var modeAutonomous = 2; function locationChanged() { alert("Lat " + blackberry.locat
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");
}
var modeCellsite=0;
var=1;
var=2;
函数位置已更改()
{
警报(“Lat”+blackberry.location.latitude+
“Lon”+blackberry.location.longitude+
“时间”+blackberry.location.timestamp);
返回true;
}
如果(window.blackberry&&blackberry.location.GPSSupported)
{
var isUpdated=false;
var计数=0;
警报(“支持位置跟踪”);
blackberry.location.onLocationUpdate(“locationChanged()”);
blackberry.location.setAidMode(modeautonomy);
同时(计数器+++<10&!已更新)
isUpdated=blackberry.location.refreshLocation();
}
其他的
{
文件。写入(“不支持位置跟踪”);
}
在运行小部件之前,请确保已在SIM卡中打开GPS
我也有同样的问题,js略有不同,但精神上相似。这对我来说没有任何改变。。。我认为设置一个位置应该和发送一个巨大的路径一样有效。@Nilloc我刚刚指出,你应该确保打开sim卡的GPS,否则你会得到0,0(默认位置)。使用“大路径”的原因是您的用户永远不会静止不动,因此您应该测试路径,而不是单个位置。我要说的是,在Java中,获取更新的位置需要几秒钟的时间,所以我认为在一个紧密循环中调用refreshlocation()不会有多大作用。我相信我所看到的示例显示了在locationChanged()处理程序中一次又一次地调用它。
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