watchPosition()

//you need an accurate GPS device to test this (like smartphone)

<script>
var x = document.getElementById("demo");
function getLocation() {
  if (navigator.geolocation) {
    navigator.geolocation.watchPosition(showPosition);
  } else {
    x.innerHTML = "Geolocation is not supported by this browser.";
  }
}
function showPosition(position) {
  x.innerHTML = "Latitude: " + position.coords.latitude + 
  "<br>Longitude: " + position.coords.longitude; 
}
</script>

Returns the current position of the user and continues to return updated position as the user moves (like the GPS in a car).

Related concepts

watchPosition()

watchPosition() — Structure map

Clickable & Draggable!

watchPosition() — Related pages: