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
Highlighted
Contributor
Posts: 10
Registered: ‎05-25-2011
My Device: Torch 9800
My Carrier: Rogers
Accepted Solution

Geolocation on Simulator 9550 5.0.0.713, 9800 6.0.0.227, and on Device with OS 6.0

Hi,

I am playing around with a really simple WebWorks app which aims to get user's geolocation.

The related javascript code is:

 // location related functions:
function getLocation() {
	if (navigator.geolocation) {
		var options;
		navigator.geolocation.getCurrentPosition(geolocationSuccess, geolocationError, options);
	} else {
		alert("HTML5 geolocation is not supported.");
	}
				
}

function geolocationError(error) {
	alert("An unexpected error occurred [" + error.code + "]: " + error.message);
}

function geolocationSuccess(position) {
	//Extract information about the users current position:
	var time = position.timestamp;
	var coordinates = position.coords;

	//Retrieve geographic information about the GPS fix:
	var lat = coordinates.latitude;
	var lon = coordinates.longitude;

	displayLocation(lat, lon);
}

function displayLocation(latitude, longitude) {
var message = "Your current location is ";
document.getElementById("locationDisplay").innerHTML = 
message + "latitude: " + latitude + ", " 
+ "longitude: " + longitude;
}

 However, the geolocation functions don't display location info on simulator 9800 6.0.0.227 (I did set location manually from "Simulator" -> "GPS Location") and on device with os 6.0 ( I did turn on Javascript and allow javascript location support), but it works on simulator 9550 5.0.0.713. 

I also find that the browser on my Blackberry device with os 6.0 can't display location info from some html5 demo websites(i.e. http://merged.ca/iphone/html5-geolocation).

Any ideas?

Contributor
Posts: 10
Registered: ‎05-25-2011
My Device: Torch 9800
My Carrier: Rogers

Re: Geolocation on Simulator 9550 5.0.0.713, 9800 6.0.0.227, and on Device with OS 6.0

Ok, update to this post:

The geolocation info is displayed on the page a few minutes after I clicked the button, it seems that both the browser and the page in my app take a while to respond...

But what about location info is not displayed on Simulator 9800 6.0.0.227?

Developer
Posts: 1,229
Registered: ‎03-20-2011
My Device: Playbook, Z10 LE, Dev Alpha B, 2x Dev Alpha C
My Carrier: 3, Orange, Vodafone

Re: Geolocation on Simulator 9550 5.0.0.713, 9800 6.0.0.227, and on Device with OS 6.0

I have a Storm 2 and a Touch

 

They react very differently to GPS tracks

 

I've sort of identified this issue as being if you are in open air or not

 

My Storm 2 ain't got a clue where I am if I sit inside my house

 

My Torch - gimme a sec - well - that failed too

 

My Droid knows exactly where I am, My Nokia thinks I live 250 miles away

 

What I think we are experiencing is too many things turned on

 

Go outside (apart from the Nokia) and you are accurately placed

 

Inside we have strong WiFi signals, compuer(s) and other things that stop the GPS lock

 

Today I went to my wife's, it's a radio-free zone - not even a chance of picking up WiFi - perfect connection

 

I got a taxi home - perfect connecton (Maps is cool when you can tell the cab driver what speed he's dong <g>)

 

Last night I had a meet with the boss - again, perfect positioning

 

The only thing that is different is that I am not surrounded by radio interference (all devices work on radio - WiFi, GPS, Bluetooth - you name it)

 

So...

 

Just try it - walk down the street, turn on maps, I'm positive you get to a few feet of where you are

 

Try the same thing with radio pullution (Home, WiFi, etc) and the GPS can't find anything

 

Believe me -the work I'm dooing requires accurate locations so this has been annoying me as well

 

At least I have the solution

 

---> Kudos - click it!




Click the like button if you find my posts useful!
Contributor
Posts: 10
Registered: ‎05-25-2011
My Device: Torch 9800
My Carrier: Rogers

Re: Geolocation on Simulator 9550 5.0.0.713, 9800 6.0.0.227, and on Device with OS 6.0

I found the same problem: if I walk around, then after a while, the GPS is able to get my position. However, with Android and iOS, I can always get my location whenever I am sitting still or walking around. Anyways...
Developer
Posts: 1,229
Registered: ‎03-20-2011
My Device: Playbook, Z10 LE, Dev Alpha B, 2x Dev Alpha C
My Carrier: 3, Orange, Vodafone

Re: Geolocation on Simulator 9550 5.0.0.713, 9800 6.0.0.227, and on Device with OS 6.0

I'm positive that being inside a building is the problem

 

A car, which is what concerns my project most, is a mobile faraday cage - if you're in a bad lightning storm stay in the car! A car is a big metal box with some windows yet if struck by lightening the occupants are perfectly safe - Richard Hammond demonstrated this on Top gear one day some years ago

 

You'd think that a car would be the worst place to have a GPS knowing what I mention above - but it's not true

 

I was travelling home by taxi last night, both my Storm 2 and Torch were perfectly positioned

 

A few days prior to this I went out shopping and watched B Maps track me, as soon as I hit a shop it lost me and as soon as I left it found me again.

 

Part of my current talk involved our app being multi-platform - BB and Android are the most important followed by Nokia S60 - I can't get the S60 I bought to even work outside Smiley Sad

 

Android and iOS are the ones that always work, BB doesn't like being in a building

 

It is possible that Android and iOS are lying to me - they may just remember my most recent position. I have a way to test that in mind and may do it tomorrow - when I get around to doing it I'll report the results




Click the like button if you find my posts useful!