Created
July 3, 2019 12:17
-
-
Save aliblackwell/0477402eee8255888a67d031d9daebb6 to your computer and use it in GitHub Desktop.
Workshop location demo
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=<device-width>, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
<style> | |
body { | |
background: #caffee; | |
margin: 0; | |
width: 100vw; | |
height: 100vh; | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
} | |
button { | |
font-size: 24px; | |
} | |
</style> | |
</head> | |
<body> | |
<button>Things around me!</button> | |
</body> | |
<script> | |
let myButton = document.querySelectorAll('button')[0] | |
myButton.addEventListener('click', () => { | |
navigator.geolocation.getCurrentPosition(position => { | |
let userLat = position.coords.latitude | |
let userLon = position.coords.longitude | |
let coords = userLat + '<br/> ' + userLon | |
document.body.innerHTML = coords | |
}) | |
}) | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment