javascripthtmlgoogle-chromegeolocationgoogle-chrome-devtools

Spoof Geolocation position.heading in Chrome DevTools


In Chrome DevTools you have the ability to spoof a location to return to the Geolocation API, by putting a lat/lon into the Sensors tab. This works well, but there doesn't seem to be a way to spoof the heading or speed or any of the other properties that are returned.

This makes testing anything that makes use of heading/speed rather difficult, as it just returns null when you override from DevTools. At the moment I am having to load my localhost application onto a real device, then unplug it, take it outside and wander round the streets, which is a little tiresome.

Does anyone know of a way to emulate the heading/speed properties without leaving my seat, either using other dev tools, a plugin or a code snippet.


Solution

  • Full disclosure, the following tool was made by myself, however it is free and open source. Only took me 5 years to get round to making it.

    A Chrome DevTools Extension is now available that allows you to override all location properties (latitude, longitude, accuracy, heading, speed, altitude and altitude accuracy).

    It also allows you to upload routes as GPX, KML or GeoJSON and then simulate the route updating in real time.

    Download from Chrome Web Store

    Download from Edge Add-ons store

    Reviews, bug reports etc. all very welcome!