Browser Geolocation

Short and sweet!

Supported Browsers:

  • Internet Explorer 9+
  • Firefox 3.5+
  • Chrome 5+
  • Safari Mobile
  • Safari 5+ has the API BUT¬†will not always return your location (Bug for a specific version? Not Hackintosh friendly?)
  • Opera 10.6+

How to get your location:

navigator.geolocation.getCurrentPosition(function(position) 
{  
    var lat = position.coords.latitude;
    var long = position.coords.longitude;
}, function(error) {
    var msg = error.message;
}); 

More information here: http://www.w3.org/TR/geolocation-API/

comments powered by Disqus