navigator.geolocation.getCurrentPosition do not work in Firefox 30.0

狂风中的少年 提交于 2019-12-30 04:37:06

问题


I am using Firefox 30.0(latest FF),navigator.geolocation.getCurrentPosition is working in Chrome but not in this version of FF.

Here is my code

    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(GEOprocess, GEOdeclined);
    }else{
      alert('Your browser sucks. Upgrade it.');
    }
function GEOdeclined(error) {
 alert('Error: ' +error.message);
}
function GEOprocess(position) {
alert('it works');
}

I am getting this error

Error: Unknown error acquiring position

Note: It stoped working only when i upgrade my FF to 30.0


回答1:


Now I'm using 47 Mozilla. I have tried everything, but all time this problem. BUT then I open about:config in my address bar, go geo.wifi.uri and changed its value to "https://location.services.mozilla.com/v1/geolocate?key=test". works!




回答2:


I've a possible solution:

I think that the mozilla guys have change something in the location adquisition process, so now it take more time and the function getCurrentPosition gets a timeout.

This will answer the question of why it works in chrome, worked in FF 29 and not in FF 30.0.

But thats a suposition. Now let's get back to the real world:

I've put a timeout of 10 seconds on the call and now it works. I've done it this way:

navigator.geolocation.getCurrentPosition(onSuccess, onError, {timeout:10000});

This fixed it for me. It works on FF 30.



来源:https://stackoverflow.com/questions/24359073/navigator-geolocation-getcurrentposition-do-not-work-in-firefox-30-0

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