Last active
May 31, 2021 09:32
-
-
Save ng-the-engineer/bc4d1bd4171a516fb46da2f6431da878 to your computer and use it in GitHub Desktop.
Code snippet of tutorial running tracker
This file contains 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
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