Advertisement
ezidan

Geolocation Example

Jan 18th, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2. var x = document.getElementById("demo");
  3. function getLocation() {
  4.     if (navigator.geolocation) {
  5.         navigator.geolocation.getCurrentPosition(showPosition);
  6.     } else {
  7.         x.innerHTML = "Geolocation is not supported by this browser.";
  8.     }
  9. }
  10. function showPosition(position) {
  11.     x.innerHTML = "Latitude: " + position.coords.latitude +
  12.     "<br>Longitude: " + position.coords.longitude;
  13. }
  14. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement