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
Developer
Posts: 66
Registered: ‎09-04-2008
My Device: Z10
Accepted Solution

Get GPS Position in specific intervall

Hi BB-Devs,

 

i´m developing an BB10 App where i use the GPS Location Services. 

I need to update my actual position in an specific intervall. 

 

First of all:

In the Ripple Simulator everything works fine. My position will be updated every x seconds. 

 

Yesterday i deployed my App with debug token to my Z10.

It seems the app works.     BUT:

When i change my position, the new position will not be updated like in the simulator :-( 

In my console log i see that my function is called every x seconds.

 

Here is a code snippet of the function which is called in the intervall:

 

function setAktPosition() {
	//First test to see that the browser supports the Geolocation API
	   if (navigator.geolocation !== null)
	   {
	      var options;
	      navigator.geolocation.getCurrentPosition(setAktPositionSuccess, setAktPositionError, options);
	   }
	   else {
	      alert("HTML5 geolocation is not supported.");
	   }
}

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

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

   //Retrieve geographic information about the GPS fix:
   ap.valueLat = coordinates.latitude;
   ap.valueLon = coordinates.longitude;
   ap.valueAlt = coordinates.altitude;
   ap.valueSpeed = coordinates.speed;
   //var acc = coordinates.accuracy;
   //var altAcc = coordinates.altitudeAccuracy;
   //var head = coordinates.heading;
   refreshMap();
}

 This is how i made to call this function in an specific intervall:

 

aktiv = window.setInterval("setAktPosition()", intervallInSec);

However - the intervall-function-call works - but my app always get the first position - no postion update when changing my location :-(

 

Of corse i made this in my config.xml:

<rim:permissions>  
   <rim:permit>access_location_services</rim:permit>
</rim:permissions>

 My app asked during the fist start to get the location permissions. I also checked this in the device settings of my Z10.

 

Are there any issues with the GPS location services in the webworks for BB10?

Or is this not possible to realise?

 

I will be happy if anyone has tips for me :-)

Thanks a lot!

 

Lars.

 

---

My Twitter:
http://twitter.com/lgentz
Developer
Posts: 212
Registered: ‎10-02-2010
My Device: Z10 and Z30
My Carrier: Play and Plus

Re: Get GPS Position in specific intervall

[ Edited ]

Sorry for question but are you trying to get position outside bulding?

 

Take a look also to this documentation:

 

https://developer.blackberry.com/html5/apis/positionoptions.html

 

I don't see your options parameters.

Developer
Posts: 66
Registered: ‎09-04-2008
My Device: Z10

Re: Get GPS Position in specific intervall

Yes - i tried it outside a building with free sight to the stars and satellites and i walked a few hundred meters to change my location.

---

My Twitter:
http://twitter.com/lgentz
Developer
Posts: 212
Registered: ‎10-02-2010
My Device: Z10 and Z30
My Carrier: Play and Plus

Re: Get GPS Position in specific intervall

Developer
Posts: 66
Registered: ‎09-04-2008
My Device: Z10

Re: Get GPS Position in specific intervall

Okay - i set the option enableHighAccuracy:true.

Also i set the option maximumAge:10000.

 

Is there any recommended minimum value for the maximumAge and timeout?

 

Thanks again for your help - now my app works like in the Ripple simulator :-)

 

 

---

My Twitter:
http://twitter.com/lgentz