Skip to content

Instantly share code, notes, and snippets.

@aliblackwell
Created July 3, 2019 12:17
Show Gist options
  • Save aliblackwell/0477402eee8255888a67d031d9daebb6 to your computer and use it in GitHub Desktop.
Save aliblackwell/0477402eee8255888a67d031d9daebb6 to your computer and use it in GitHub Desktop.
Workshop location demo
<!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