Geolocation API

User grants access their to device location, accessible via lat/long co-ords.


  • Location based services
  • User tailored content based on location
  • Navigation/Sat Nav systems
  • From me to you (delivery/journey time)
  • Better cultural content (not just based on lang)


// Is geolocation supported?
if (navigator.geolocation) {
  // get current position
    // to run on success
    function(position) {
      var lat = position.coords.latitude;
      var lon = position.coords.longitude;
      var accuracy = position.coords.accuracy;
      // there is also altitude, altitude accuaracy, heading and speed methods
    // to run on fail
    function(error) {
      console.warn('no position found');

// as well as the above there are is a watchPosition method - see the links for more info