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: 33
Registered: ‎08-29-2008
My Device: Not Specified

GPS issue on BB10

I want to develope a GPS application on BlackBerry 10 using WebWorks. I wonder if you can help me solve the following questions:

  1. How to check if the GPS permission is set? I have <rim:permit>access_location_services</rim:permit> in config.xml file, but the user may uncheck the GPS permission the first time. I have to chcek if the user set the GPS permission for my app everytime my app is loaded.      

2. If the GPS permission is not set, how to let user set the GPS permission for my app?

 

Thank you.

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

Re: GPS issue on BB10

Hi jian,

 

you can check if geolocation is supported:

 

if(navigator.geolocation){
      alert("geolocation is supported!");
   }else{
      alert("geolocation is not supported!");
   }

 

---

My Twitter:
http://twitter.com/lgentz
Developer
Posts: 66
Registered: ‎09-04-2008
My Device: Z10

Re: GPS issue on BB10

Also you can have a look at this:

 

http://developer.blackberry.com/html5/apis/blackberry.system.html#.hasCapability

 

location.gps

 

But i think all the BB10 Devices will have GPS on board...

 

---

My Twitter:
http://twitter.com/lgentz
Developer
Posts: 23
Registered: ‎01-05-2013
My Device: 9800
My Carrier: IDEA

Re: GPS issue on BB10

Highlighted
Developer
Posts: 553
Registered: ‎10-31-2009
My Device: Torch 9800, Bold 9700
My Carrier: Movistar, Telenor

Re: GPS issue on BB10

Another alternative is to use Geolocation watchposition.

 

I start and save last location in localstore. If
I want to access it I query the datastore

 

function startTracking()
{
navigator.geolocation.watchPosition
 
  (function(position)
     {
      var latpos = position.coords.latitude;
      var longpos = position.coords.longitude;    
      localStorage["Longitude"] = longpos;
      localStorage["Latitude"] = latpos;
     }
   );
 }
 
function supports_html5_storage() {
  try {
    return 'localStorage' in window && window['localStorage'] !== null;
  } catch (e) {
    return false;
  }
}

function getGPS3()
 {
   var longitude = localStorage["Longitude"];
   var latitude = localStorage["Latitude"];
   alert("Longitude: " + longitude + "Latitude: " + latitude);
 }

If everything seems to be under control, you're just not driving fast enough
-Mario Andretti-