just some browser console utils i have for location debugging
Created
December 9, 2025 13:06
-
-
Save karol-broda/6f5ad14b6ca78c61b61a6338ac9ca69e to your computer and use it in GitHub Desktop.
browser console location
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| navigator.geolocation.getCurrentPosition( | |
| function (position) { | |
| console.log("lat:", position.coords.latitude, "lng:", position.coords.longitude); | |
| }, | |
| function (error) { | |
| console.log("error:", error); | |
| } | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function overrideGeolocation() { | |
| var originalGetCurrentPosition = navigator.geolocation.getCurrentPosition; | |
| var originalWatchPosition = navigator.geolocation.watchPosition; | |
| var mockCoords = { | |
| latitude: 52.520008, | |
| longitude: 13.404954, | |
| accuracy: 10 | |
| }; | |
| navigator.geolocation.getCurrentPosition = function (successCallback, errorCallback, options) { | |
| successCallback({ | |
| coords: mockCoords, | |
| timestamp: Date.now() | |
| }); | |
| }; | |
| navigator.geolocation.watchPosition = function (successCallback, errorCallback, options) { | |
| var watchId = Date.now(); | |
| successCallback({ | |
| coords: mockCoords, | |
| timestamp: Date.now() | |
| }); | |
| return watchId; | |
| }; | |
| console.log('geolocation overridden with mock coordinates', mockCoords); | |
| }()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment