Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Developer
Posts: 53
Registered: ‎06-14-2010
My Device: Simulator

Sand in the Gears

I'm trying to do what appears to be relatively simple: Use the gears API to get location data. From the lab, I'm using the sample 3 functions below. The main page is setup so that a user click on a menu item calls GeoLocateMe().

 

I do have a location set in the Simulate > Gps Location.

 

When the function executes, geoError returns "null".

 

WindowsXP Pro, testing simulators 9550 Storm and 9700 Bold.

 

I do have featureIDs set in the config.xml for the namespaces used.

 

Any advice on this one? Anyone using these functions?

 

*************************** 

function displayLocation(loc) {

mapLocation(loc.latitude, loc.longitude);

document.getElementById('results').innerHTML = loc.latitude + loc.longitude;

}

 

function geoError(err) {

alert("Error: " + err.message);

}

 

function geoLocateMe() {

var geo = google.gears.factory.create('beta.geolocation');

geo.getCurrentPosition(displayLocation, geoError);

}

New Developer
Posts: 53
Registered: ‎06-14-2010
My Device: Simulator

Re: Sand in the Gears

Hmmmmmmm... a little followup. I ran the Blackberry Widget GPS Lab sample as it was provided and it did the same thing: could find hard-coded locations but could not find My Location (returned null in geoError too). So, I'm wondering, has anyone ever successfully ran that sample? If so, what's the secret key to finding My Location or a simulated location?

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Sand in the Gears

Hi Ekey,

 

Are you wanting the simulator to find out your current GPS location?  The simulator requires you to simulate GPS locations because it does not have a GPS receiver.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
New Developer
Posts: 41
Registered: ‎06-22-2010
My Device: N/A

Re: Sand in the Gears

[ Edited ]

I'd like to add my comments to the OP.

 

I've just tried the gears approach after reading in the docs that the blackberry location object is now considered legacy.

 

I've added in following code:

 

 

function displayLocation(loc) {
	alert(loc.latitude, loc.longitude);
}
function geoError(err) {
	alert("error: " + err);
}
function GetGPSLocation() {
	if(blackberry.system.hasCapability("location.gps")){
		var geo = google.gears.factory.create('beta.geolocation');
		geo.getCurrentPosition(displayLocation, geoError);
	}
}

 

 

I have set my location in the simulator via the Simulate -> GPS Location menu item.

When I run the GetGPSLocation() function, the simulator pauses for a while and then returns the message:

 

 

error: [object net.rim.device.apps.internal.browser.gears.PositionError]

 The code I've used above is from the BB labs "Lab_Widget_GPS" example. In the original code, the error callback function alerts err.message, which when I run it in my code returns "null" (probably the same deal as the OP).

 

I'm wondering - do we need to include the js file gears_init (from code.google.com)? I was under the impression Gears was built in to platform 5.0 and up, yet the labs example explicitly includes this JS file (note in my code I have not included this file, but the geo object still returns an object leading me to believe gears is pre-loaded).

 

Using simulators Storm2 9550 and Bold 9700 (the latter shows the error, the former does nothing much at all)

 

Cheers

 

Lee

 

[EDIT]

In the error handler I added:

 

alert("err.POSITION_UNAVAILABLE: " + err.POSITION_UNAVAILABLE);
alert("err.TIMEOUT: " + err.TIMEOUT);
alert("err.code: " + err.code);
alert("err.message: " + err.message);

 

 

All returned undefined except err.code, which returned 2. Checking the W3C spec this apparently means POSITION_UNAVAILABLE.

 

Any thoughts on the cause? My simulator is definitely set up to return pretend GPS long and lat data.

 

=============================
Win 7 (32bit)
Eclipse Galileo
BlackBerry Web Plug-in
Version: 2.0.0.201003191451-33
BlackBerry Widget SDK
Version: 1.0.0.201003191451-126
=============================
Retired
Posts: 46
Registered: ‎07-08-2010
My Device: Superberry

Re: Sand in the Gears

Hi Sibbaldl,

 

Which version of the 9550 and 9700 device software are you running? Start the simulator up, go to Options -> About, and you'll see it on the 3rd line of that page as: v5.0.0.X etc.

-------------------------------------------------------------------------------------------------
Useful resources, food for the brain:
Web(Works) KB - http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/tkb-p/browser_dev%40tkb
New Developer
Posts: 41
Registered: ‎06-22-2010
My Device: N/A

Re: Sand in the Gears

Hi ababut

 

Both devices are version 5.0.0.469

 

=============================
Win 7 (32bit)
Eclipse Galileo
BlackBerry Web Plug-in
Version: 2.0.0.201003191451-33
BlackBerry Widget SDK
Version: 1.0.0.201003191451-126
=============================
New Developer
Posts: 53
Registered: ‎06-14-2010
My Device: Simulator

Re: Sand in the Gears

My understanding is that using this function call with this api will return the simulated location that is entered at the simulator menu item Simulate > Gps location ...

New Developer
Posts: 41
Registered: ‎06-22-2010
My Device: N/A

Re: Sand in the Gears

Yes, that's my understanding too. Except as I've described above, it doesn't (not for me anyways) :smileysad:

=============================
Win 7 (32bit)
Eclipse Galileo
BlackBerry Web Plug-in
Version: 2.0.0.201003191451-33
BlackBerry Widget SDK
Version: 1.0.0.201003191451-126
=============================
Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Sand in the Gears

We have discovered that some of the 5.0 simulators have issues with simulating GPS coordinates... Let me talk to the group and see which ones are affected.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Retired
Posts: 46
Registered: ‎07-08-2010
My Device: Superberry

Re: Sand in the Gears

5.0.0.469 is the simulator bundle in which Gears cannot get a GPS position.

 

I have tried your code and it works on the Generic 5.0 344 bundle found at:

 

http://na.blackberry.com/eng/developers/resources/simulators.jsp

 

Please give it a shot and let us know if you're seeing any more issues.

 

 

 

-------------------------------------------------------------------------------------------------
Useful resources, food for the brain:
Web(Works) KB - http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/tkb-p/browser_dev%40tkb