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

Posts: 174
Registered: ‎01-25-2011
My Device: Not Specified

Retrieving GPS location in browser field using html5

Hi all,

We are developing a hybrid applications in which we have a section of pages which actually require GPS location to be shown. I have tried the following two links to do it.




One thing i observe is both the javascript codes retrieve the correct locations when the user is outside(I mean when the user has a clear sky). But I want the user to be able to retrieve the current location even when he is inside the bulidings with both WIFI and SIM card. What am i missing as both the links says that the code supports in all the cases. 

I also see the same code being mentioned in KB article below, but has proven to be inefficient and inadiquate


Bottom line---

Am i doing some thing wrong???

Is there a better way to detect GPS locations with WIFI and SIM from javascript ???

Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Retrieving GPS location in browser field using html5

Hi there,

The most recent documentation on this can be found here:

You might try explicitly setting PositionOptions when you request the position:

For low accuracy, enableHighAccuracy would be set to false, otherwise it will try to use the GPS hardware which would not work so well indoors.

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Posts: 174
Registered: ‎01-25-2011
My Device: Not Specified

Re: Retrieving GPS location in browser field using html5

let me tell u one interesting fact.. we have gone through the all the latest docs regardg that, but none of them worked in india... but all of the possibilities worked perfectly in canada.... i wonder does the html5 geolocation has something to do with the location in BB.... i think bb has to look into this n resolve the issue...
BlackBerry Development Advisor
Posts: 768
Registered: ‎10-01-2009
My Device: All
My Carrier: N/A

Re: Retrieving GPS location in browser field using html5



Here's my implementation of HTML5 Geolocation.  It works from inside buildings, and pretty much everywhere for me.  I'm using the high accuracy 'mode', but it can be changed quite easily in the code.  I hope it helps in your case.


// we use HTML5 Geolocation to pin-point where the user is
function startGeolocation() {
	setTimeout(function() {
		$('#message').fadeIn(300).html('Getting your position...');
	}, 100);
	var options;  // here you can specify different options, in my case, there are none
	navigator.geolocation.getCurrentPosition(geoSuccess, geoFail, options);

// geolocation success callback
function geoSuccess(position) {
	var gpsPosition = position;
	var coordinates = gpsPosition.coords;

// we now have coordinates, let's do something with them
doSomething(coordinates.latitude, coordinates.longitude); } // geolocation failure callback function geoFail() { alert('Couldn\'t get your position...'); return false; }