1

I'm currently searching a way for device using firefox OS to communicate with device's gps, so it can get the exact location positioning, rather than the w3c geolocation api which is not as accurate as gps realtime.. Thanks!

3 Answers 3

3

Simple answer: it isn't possible to access the "device's GPS" directly. You only have the Geolocation API that you already know.

Long answer: My experience with it is not bad at all. So, I think only of two possibilities for not getting "exact location positioning", as you name it:

  1. maybe you're not using the right options to get a precise position. In this case, you could tweak your options a bit to get better results;
  2. maybe you're not waiting until the underlying software can use your GPS instead of some less accurate instrument/estimation (like Wi-Fi positioning estimation).
  3. It can be a combination of both =P

In the first case, you can verify if you're using enableHighAccuracy, like this:

navigator.geolocation.watchPosition(
  successCallback,
  errorCallback,
  { enableHighAccuracy: true }
);

This will ask the browser for better results, as the standard indicates. Watch out that this may use more battery, and this may not be available anyway. This may take more time too, which is related to my other observation.

In the second case, you may be using a value for timeout that is too small, and maybe it's combined with a maximumAge that may be too high.

If maximumAge is high and timeout is small, you get an out dated position, as there won't be enough time to get a new position and you accept an old one.

If both are small, you'll start to get lots of TIMEOUT errors (the value is 3), as there'll be no positions for you.

You need to find the right balance between all 3 options to get the best positions. And you have to be patient sometimes.

Play with all 3 options and take a look at the errors you get. They'll tell you a lot about your issue getting precise and accurate coordinates.

The position object has some attributes that may come in handy to analyze what's happaning:

  • the position.timestamp attribute will tell you how old that position object is. If this is old, you know you should tweak the options
  • the position.coords.accuracy attribute will tell you the accuracy level of the lat/long coordinates. If this is too big (it's in meters), you know you should tweak the options

If you wait forever, on a place where the GPS should work well (say, outdoors, on a clean field), and you keep getting inaccurate results, maybe you can't do much better anyway. I'd say it's not possible anyway, with your software+hardware =(

1
  • I see, very detailed explanation. Thanks! Haven't got the real device to play with though, just wondering about how good the webAPI will work with the hardware of the phone.
    – wira
    Mar 22, 2013 at 14:14
1

As of now, Firefox OS only has support for GPS positioning (with the latest addition of A-GPS in the mix). That results in the fact, that most of the time you will have to wait from 1 to several minutes at least for the GPS module to acquire lock on your location, and you will need clear look at the sky for the lock to be acquired.

That said, after a lock is acquired, by using the right settings in the call itself (like setting the enableHighAccuracy flag to true) the GPS should provide as accurate position as any other device would.

Right now cell-based and wifi-based geolocation is not available in the current version of the OS (1.0.1 or 1.1.0, either) but is in the pipeline.

0

You can use the Geolocation API Firefox OS or Google Maps (I do not remember where I got it)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.