/dev tips

(206) Performance Recordings with Code Coverage Push Notification Debugging (208)

Chrome DevTools: Override your geolocation with predefined areas or custom locations

4th October 2019
Override your geolocation with predefined areas or custom locations

JavaScript 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:

  1. Access the Sensors Pane using the Command Menu (Cmd + Shift + P and type in sensor)
  2. No override is selected by default. Click on the options to select a geographic location of your choice
  3. 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.

Sign up to receive a developer tip, in the form of a gif, in your inbox each week.