Guest User

Untitled

a guest
Oct 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. // var x = document.getElementById("demo");
  2.  
  3. function getLocation() {
  4. if (navigator.geolocation) {
  5. navigator.geolocation.getCurrentPosition(showPosition);
  6.  
  7. } else {
  8. x.innerHTML = "Geolocation is not supported by this browser.";
  9. }
  10. }
  11.  
  12. function showPosition(position) {
  13.  
  14. var longitude = position.coords.longitude;
  15. document.getElementById('id_longitude').value = longitude;
  16.  
  17. latitude = position.coords.latitude;
  18. document.getElementById('id_latitude').value = latitude;
  19. }
Add Comment
Please, Sign In to add comment