BlackBerry Widget application - GPS location is always 0,0

时光怂恿深爱的人放手 提交于 2020-01-25 08:25:06

问题


I am trying to get the GPS location in a widget application on a blackberry, but the API always returns a latitude and longitude of 0,0.

Simulator: storm 2 (9550)/ bold(9700) and OS: 5.0/5.0

IDE:Eclipse

the html page code as below:

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");
}

回答1:


Make sure you turned ON GPS in the SIM before running your widget.

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


来源:https://stackoverflow.com/questions/3989166/blackberry-widget-application-gps-location-is-always-0-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!