2

What is the most stable way to use a browsers (Firefox, iPhone's Safari, Android) navigator.geolocation functionality?

Both navigator.geolocation.getCurrentPosition and navigator.geolocation.watchPosition seems unstable, they some times ends up in success callback and sometimes ends up in error callback and I cannot see the reason.

I'm now using:

navigator.geolocation.getCurrentPosition(function (position) {
    console.debug(position);
}, function(data) {
    console.debug(data);
},
{
    enableHighAccuracy: true,
    maximumAge: Infinity,
    timeout: 10000
});

Is there any JavaScript framework that makes reading geolocation (cross browser) more stable.

What is it that is causing the instability, something in the browsers core?

I have had problems in Firefox (Ubuntu, Mac), Chrome (Mac), Safari (Mac), iPhone. Chrome for Ubuntu seems to be working alright.

Please share on how you have implemented geolocation in your project or any ideas on how to improve the quality of the readings.

tirithen
  • 3,219
  • 11
  • 41
  • 65
  • I'm having issues with this too right now. Sometimes Firefox fails, and sometimes it doesn't. And sometimes it gives results that are nowhere near me. – adamzwakk Feb 14 '11 at 16:46
  • The accuracy of the readings seem to depend on what you set maximumAge to, with value set to Infinity it seemes like the faliures are more common but the accuracy is better, with value set to 0 it seemes like success is more common but accurancy is kilometers wrong. These tests was done on Chrome with broadband connection. I'm not sure if these assumptions are correct... – tirithen Feb 14 '11 at 21:57

1 Answers1

1

Here's some more information about the unreliability of geolocation:

navigator.geolocation.getCurrentPosition sometimes works sometimes doesn't

Community
  • 1
  • 1
craigmoliver
  • 6,499
  • 12
  • 49
  • 90