Skip to content

Instantly share code, notes, and snippets.

@it-one-mm
Last active May 21, 2020 16:03
Show Gist options
  • Save it-one-mm/5d5ddaf7257e1557b70bb2af799e3437 to your computer and use it in GitHub Desktop.
Save it-one-mm/5d5ddaf7257e1557b70bb2af799e3437 to your computer and use it in GitHub Desktop.
Fake Locations To Test for Expo Client App
import * as Location from 'expo-location';
const tenMetersWithDegrees = 0.0001;
const getLocation = (increment) => {
return {
timestamp: 1000000,
coords: {
speed: 0,
heading: 0,
accuracy: 5,
altitudeAccuracy: 5,
altitude: 5,
longitude: -122.0312186 + increment * tenMetersWithDegrees, // add your current longitude
latitude: 37.33233141 + increment * tenMetersWithDegrees, // add your current lattitude
},
};
};
let counter = 0;
setInterval(() => {
Location.EventEmitter.emit('Expo.locationChanged', {
watchId: Location._getCurrentWatchId(),
location: getLocation(counter),
});
counter++;
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment