Skip to content

Instantly share code, notes, and snippets.

@mittsh
Created July 10, 2019 12:11
Show Gist options
  • Save mittsh/fe1aff91354c7f21bd59b99cc51088ee to your computer and use it in GitHub Desktop.
Save mittsh/fe1aff91354c7f21bd59b99cc51088ee to your computer and use it in GitHub Desktop.
Simulate a fake location in browser API
navigator.geolocation.getCurrentPosition = (fn) => {
setTimeout(() => {
fn({
coords: {
accuracy: 40,
altitude: null,
altitudeAccuracy: null,
heading: null,
latitude: 13.705848,
longitude: 100.622798,
speed: null,
},
timestamp: Date.now(),
})
}, 2912)
}
@librevlad
Copy link

Thanks man! setTimeout is what makes this thing consistent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment