[raw]
Click the button to get your coordinates:
[/raw]
<!DOCTYPE html> <html> <body> <p id="demo">Click the button to get your coordinates:</p> <button onclick="getLocation()">Try It</button> <script> var x=document.getElementById("demo"); function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(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 + "<br>Map: <a href=http://maps.google.com/?q=" + position.coords.latitude + "," + position.coords.longitude + " target=_blank>http://maps.google.com/?q=" + position.coords.latitude + "," + position.coords.longitude + "</a>"; } </script> </body> </html>
Source: http://www.w3schools.com/html/html5_geolocation.asp
Last Updated on October 26, 2015