Skip to content

Commit

Permalink
Added notes and solution for Project 21 - Geolocation based Speedomet…
Browse files Browse the repository at this point in the history
…er and Compass
  • Loading branch information
lisaychuang committed Jun 4, 2018
1 parent aec5c2e commit 69c6cc3
Show file tree
Hide file tree
Showing 3 changed files with 2,925 additions and 2 deletions.
19 changes: 19 additions & 0 deletions 21 - Geolocation/index-projectnotes.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ <h1 class="speed">
/*Compass: https://thenounproject.com/search/?q=compass&i=592352*/
</style>
<script>
// Browser are shipped with self-signed certificate

// select arrow & speed display
const arrow = document.querySelector('.arrow');
const speed = document.querySelector('.speed-value');

// watch ongoing position
console.log('Start watching position')

navigator.geolocation.watchPosition((data) => {
console.log(data);
speed.textContent = data.coords.speed;
arrow.style.transform = `rotate(${data.coords.heading}deg)`;

}, (err) => { // callback fn to handle error
console.err(err);
alert('Please turn on Location access!');
});

</script>
</body>
</html>
Loading

0 comments on commit 69c6cc3

Please sign in to comment.