navigator.geolocation.getCurrentPosition do not work in Firefox 30.0
Asked Answered
M

2

12

I am using Firefox 30.0 (latest FF), and 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 stopped working after upgrading Firefox to version 30.0

Matthus answered 23/6, 2014 at 5:43 Comment(0)
J
29

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!

Jessamine answered 13/7, 2016 at 14:35 Comment(6)
Changing the uri worked for me too, seems like google is blocking something.Lidstone
but client need to do setting for geolocation, is there any way to modify that setting through coding or instead of setting can we get geolocation through other wayAnemone
@Abhijit Jagtap i needed it only for my local environment.Jessamine
Thanks @VasylGutnyk for a reply, but do you have any idea, how do I implement it at client side?Anemone
@Abhijit Jagtap didn't work with smth like that. but maybe this library can help u: github.com/pyllyukko/user.jsJessamine
The config key has changed from "geo.wifi.uri" to "geo.provider.network.url". I'm using FF 76Stodge
Y
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.

Yip answered 24/6, 2014 at 9:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.