DanieleCalisti

file1

Sep 1st, 2020 (edited)
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (navigator.geolocation) {
  2.   navigator.geolocation.getCurrentPosition(mia_posizione);
  3. }else{
  4.   alert('La geo-localizzazione NON è possibile');
  5. }
  6.  
  7. var pos = []
  8.  
  9. //Non posso usare questa funzione nel file 2.js perchè non ho la variabile position
  10. function mia_posizione(position) {
  11.   var lat = position.coords.latitude;
  12.   var lon = position.coords.longitude;
  13.  
  14.   pos = [lat,lon]
  15.  
  16.   document.getElementById('posizione').innerHTML = 'La tua posizione: ' + lat + ',' + lon;  
  17. }
  18.  
  19.  
  20. function ritornaArray()
  21. {
  22.     //Mi ritorna l'array vuoto
  23.     return pos
  24. }
Advertisement
Add Comment
Please, Sign In to add comment