开发者

Firefox 5, Geolocating and "Not Now" Issue

开发者 https://www.devze.com 2023-03-25 21:11 出处:网络
Has anyone out there had to deal with and managed to find a vi开发者_StackOverflow中文版able workaround for the Firefox 5 geolocation issue I posted in the following bug report. It\'s easier to link t

Has anyone out there had to deal with and managed to find a vi开发者_StackOverflow中文版able workaround for the Firefox 5 geolocation issue I posted in the following bug report. It's easier to link to the report than re-describe it here.

https://bugzilla.mozilla.org/show_bug.cgi?id=675533

Surely I'm not the only one on the planet this has bitten.


This doesn't really solve the root of your problem but my strategy for handling this is setting a default location point that I use right away (not waiting for the geolocation question to be answered).

If I get a location from the user, I just change it to the new location. If I get a rejection or no answer at all, I just stay on the default location.

It's also my experience that a desktop client (in my case Firefox on a stationary Windows computer) takes much longer to respond than a mobile client (in my case Safari on iPhone). I was forced to set the timeout to 10 seconds (10000) to give the desktop client enough time to respond. So if you have a map, initializing it and centering on a default location directly will give the user a map on the screen much faster than if you have to wait for a response.

Good luck with your positioning project!


I might be a bit late but hope I can help others. My workaround is based on a delayed call. If there is no fix when the delayed call is fires, I become suspicious :)

var timeIsPassig = false;

function anyThing(){
  timeIsPassig = true;
  setTimeout(
    function(){
      if (timeIsPassig) {
        timeIsPassig = false;
        console.log("Waiting too much... Or did you say not now? :-P");
        }
      },
    10000
    );
  navigator.geolocation.getCurrentPosition(
    function (pos) {timeIsPassig = false; /* rest of positioning*/},
    function (err) {timeIsPassig = false; /* rest of error handling*/},
    {maximumAge: 30000, timeout: 10000, enableHighAccuracy: true}
    )
  }
0

精彩评论

暂无评论...
验证码 换一张
取 消