Fixing geolocation in Firefox on Ubuntu

For some reason, it seems Firefox on Ubuntu isn’t able to perform geolocation successfully. By default, the API it uses is https://www.googleapis.com/geolocation/v1/geolocate?key=%GOOGLE_API_KEY% and a failure can mean the API key is missing, or it doesn’t work.

According to this chromium-packages thread, the API key is returning an error. That thread’s linked to from this launchpad bug report. According to the former thread, Chromium packages also have an issue, on both Ubuntu and Arch.

You can find other discussions online about similar issues that seem to imply the API key itself is missing, but I haven’t found a way of checking that (not that I looked too hard).

The fix: set geo.wifi.url to https://location.services.mozilla.com/v1/geolocate?key=%MOZILLA_API_KEY%

Honestly, I don’t see why the default is the Google API anyways; the Mozilla one works well enough, and I help it out by running Firefox on my phone and allowing it to collect data. Given that it collects location data from my phone that’s usually within a few feet of my laptop, I figure Mozilla will return geolocation results that are accurate to within a few feet.

Published on February 09, 2020.