html geolocation: Unknown error acquiring position
Asked Answered
B

1

8

I am trying to use HTML geolocation to get my position. Funny thing is, it was working brilliantly until some seemingly random point in the day when it just stopped working. Now all I get is the error callback with a message:

Unknown error acquiring position

This happened on the day I first started to develop the app. It is a web app built in Node/Express. The browser I am using is Firefox v53 64-bit.

Location is allowed, and I have also tried a fix that I found online which involves going to about:config and changing geo.wifi.uri from:

https://www.googleapis.com/geolocation/v1/geolocate?key=%GOOGLE_API_KEY%

to

https://www.googleapis.com/geolocation/v1/geolocate?key=test

This did not work for me.

This does however work on my phones Firefox app, but not the Google Chrome app.

Heres an example code snippet:

    const geo = navigator.geolocation;
    geo.getCurrentPosition(success, failure);

    function success(position) {
        lat = position.coords.latitude;
        lng = position.coords.longitude;
        $('#coords').val(lat + ',' + lng);
        mapView.setCenter(ol.proj.fromLonLat([lng, lat]));
    }

    function failure(error) {
        console.log(error.message);
    }

The full page: https://github.com/ThriceGood/Spots/blob/master/views/index.html

Can anyone shed some light on this issue?

Butterworth answered 27/6, 2017 at 6:7 Comment(4)
and changing the line - which config item is that!!??Delorenzo
sorry, its: geo.wifi.uriButterworth
well, mine is https://location.services.mozilla.com/v1/geolocate?key=%MOZILLA_API_KEY% - - notice how it doesn't use googleapi's at all!!! also, the config item doesn't exist in my phone at allDelorenzo
thank you. It would seem that using that uri for my location service does not fix it for me.Butterworth
R
8

What worked for me was changing geo.wifi.uri to:

https://location.services.mozilla.com/v1/geolocate?key=test

As per this page: navigator.geolocation.getCurrentPosition do not work in Firefox 30.0

Raffo answered 1/11, 2017 at 4:26 Comment(3)
This fix worked for me with Firefox 61 on Ubuntu 16.04. Thanks!Styptic
How to do this in the client machine? programmatically?Stagecoach
The config key has changed from "geo.wifi.uri" to "geo.provider.network.url". I'm using FF 76Threat

© 2022 - 2024 — McMap. All rights reserved.