DEV Community

Dominika Zając (she/her) 🇵🇱
Dominika Zając (she/her) 🇵🇱

Posted on

How to mock location in the web without installing additional tools

Geolocation is super useful feature in our apps. It doesn't matter if you want to find a way in a new city or just order food to home - you can just click one button and avoid typing a long address. As developers we know a lot of ways to implement location in web — but how can we test if it works properly? The answer is: just use your browser. How to do that?

  1. Open the Chrome browser
  2. Go to page you want to test
  3. Open Chrome DevTools (ctrl + shift + I on Linux/Windows or cmd + shift + I on Mac)
  4. Click 3 dots on the right side.
  5. Choose More Tools and Sensors
  6. Check Geolocation section

As you can see you have a lot of options available here. You can choose one of the default places defined in the dropdown menu (like London, Berlin, or Shanghai) or define your own latitude and longitude. When you often use some location that is not available by default you can click Manage and Add location to add your custom place to presets. You can also check how your webpage behaves when some errors occurred and data are unavailable — it’s enough to choose the Location unavailable option from the menu. Voila! It just works! You don’t need to drive around the city with a laptop on your knees or install some third-party software. Quite nice — don’t you think?

Top comments (0)