Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I test geolocation javascripts?

I'm currently working on some geolocation javascripts, but am unable to test and debug them properly: My desktop machine (Running Windows, with Chrome 5 or Firefox 3) doesn't have location information and my mobile devices don't feature any debugging capabilities.

How can I test geolocation scripts? Is there a tool which will fake a GPS sensor?

like image 223
Christian Studer Avatar asked Jul 06 '10 08:07

Christian Studer


3 Answers

In Firefox, it's possible to switch the default Geolocation provider (Google) to a manually entered source.

Fake your geolocation in Firefox 3.5

All you need for faking is a text file (eg. /home/username/.mynewlocation.txt) somewhere on your computer with the following content: {"location":{"latitude":50.941863,"longitude":6.958374, "accuracy":20.0}}

The path in Firefox to this file is: file://home/username/.mynewlocation.txt

Type about:config in your location bar, confirm the warning, search for geo.wifi.url, and replace the old url (https://www.google.com/loc/json) with your new one from above. Restart firefox, enjoy your new location :-)

And there's a similar SO question with a number of good answers as well.

like image 115
Pekka Avatar answered Oct 19 '22 00:10

Pekka


In chrome, you can now use the manual geolocation chrome extension to set your location manually.

like image 21
ronme Avatar answered Oct 18 '22 22:10

ronme


Chrome now (tested in version 25) supports Geolocation spoofing via Developer Tools

like image 3
mvark Avatar answered Oct 18 '22 22:10

mvark