BlackBerry Widget application - GPS location is al

2019-08-30 05:40发布

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条回答
Deceive 欺骗
2楼-- · 2019-08-30 06:20

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
查看更多
登录 后发表回答