Firefox 5, Geolocating and “Not Now” Issue

纵饮孤独 提交于 2019-11-29 14:03:14

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}
    )
  }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!