Chrome DevTools: Override your geolocation with predefined areas or custom locations
Last updated: 4th October 2019JavaScript code can query your location like this:
navigator.geolocation.getCurrentPosition(console.log)
In the DevTools Sensors Pane, you can override the latitude and longitude from a set of predefined options, or you can define your own locations. This feature can be useful for working on pages which makes use of geolocation. To try this out:
- Access the Sensors Pane using the Command Menu (Cmd + Shift + P and type in
sensor
) No override
is selected by default. Click on the options to select a geographic location of your choice- You can execute the code
navigator.geolocation.getCurrentPosition(console.log)
in the Console Panel to observe that the location has been overridden
Bonus: Select the Manage
button to define new locations. You can specify a name, latitude and longitude.