Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Geolocation provider for Firefox that allows manual input

Are there any easy ways to override the default behaviors of the geolocation api and just hard code your current location?

I think this would be useful for testing and for privacy reasons (providing fake location data)

I thought there was an add on for this but I can't seem to find one. Only option right now seems to be changing the about:config geo.wifi.url to some alternative webservice, which I consider overly complicated.

Any ideas?

Thanks

Ideal Scenario

Somebody implements an add-on where a google map appears and I can pick a new default location.

like image 917
Ryu Avatar asked Nov 26 '09 00:11

Ryu


People also ask

What is geolocation Navigator?

The Navigator geolocation property is used to return a geolocation object by the browser which can be used to locate a user's position. It is a read-only property and is only available on the approval of the user since it can compromise the user's privacy. Syntax: navigator.geolocation.

Is geolocation a Web API?

The Geolocation API allows the user to provide their location to web applications if they so desire. For privacy reasons, the user is asked for permission to report location information. WebExtensions that wish to use the Geolocation object must add the "geolocation" permission to their manifest.


2 Answers

The easiest way is to navigate to about:config and then in the filter box enter geo.wifi.uri, double-click the only config row that shows up, and enter the value below after you replace xxx and yyy with the co-ordinates you get from a service like http://www.getlatlon.com/:

data:application/json,{"location":{"latitude":xxx,"longitude":yyy,"accuracy":10}}

This trick doesn't require any add-ons or local/hosted files. Make sure the value is without any spaces and is on a single line!

like image 161
nikolay Avatar answered Oct 06 '22 22:10

nikolay


The geo.wifi.uri does not need to be a webservice. You can also set it to a local uri with file://...

The file should be a json file with content like this:

{"location": {
              "latitude": 48.777025000000002, 
              "longitude": 9.1713909999999998, 
              "accuracy": 10.0}}

Update: For Firefox 9+, the format has changed:

{
    "status": "OK",
    "accuracy": 10.0,
    "location": {"lat": 48.777, "lng": 9.171}
}

Or you can combine them to support both:

{
    "status": "OK",
    "accuracy": 10.0,
    "location": {
        "lat": 48.777,
        "lng": 9.171,
        "latitude": 48.777,
        "longitude": 9.171,
        "accuracy": 10.0
    }
}

Update: it looks like manually setting this preference is blocked by the provider assuming the Google service. See Bug 716453 Update 2: geo.wifi.uri not geo.wifi.url

like image 31
Peter Hoffmann Avatar answered Oct 06 '22 22:10

Peter Hoffmann