Skip to content

Instantly share code, notes, and snippets.

@ng-the-engineer
Last active May 31, 2021 09:32
Show Gist options
  • Save ng-the-engineer/bc4d1bd4171a516fb46da2f6431da878 to your computer and use it in GitHub Desktop.
Save ng-the-engineer/bc4d1bd4171a516fb46da2f6431da878 to your computer and use it in GitHub Desktop.
Code snippet of tutorial running tracker
const success = (position) => {
const { latitude, longitude } = position.coords;
const timestamp = (new Date(Date.now())).toISOString();
...
createNewEvent(latitude, longitude, timestamp);
}
const createNewEvent = (latitude, longitude, timestamp) => {
const geoEvent = new CustomEvent("GEO_EVENT", {
detail: {
latitude,
longitude,
timestamp,
},
bubbles: true,
cancelable: true,
composed: false,
});
document.querySelector("#tracker").dispatchEvent(geoEvent);
}
document.querySelector("#tracker")
.addEventListener("GEO_EVENT", updateMap);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment