Skip to content

Instantly share code, notes, and snippets.

@marcusasplund
Created November 23, 2017 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcusasplund/6bee62385985886be562f338c7b38b06 to your computer and use it in GitHub Desktop.
Save marcusasplund/6bee62385985886be562f338c7b38b06 to your computer and use it in GitHub Desktop.
// getCurrentPosition()
// .then((position) => console.log(position.coords.latitude))
const getCurrentPosition = () => {
return new Promise((resolve, reject) => {
window.navigator.geolocation
.getCurrentPosition((position) => {
resolve(position)
}, (error) => {
reject(error)
},
{
enableHighAccuracy: true
}
)
})
}
export {getCurrentPosition}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment