Advertisement
Guest User

geoloc

a guest
Jun 4th, 2019
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [code=javascript]
  2. <html>
  3. <body>
  4. <script>var Geolocalizacion = navigator.geolocation || (window.google && google.gears && google.gears.factory.create('beta.geolocation'));
  5. if (Geolocalizacion) Geolocalizacion.getCurrentPosition(MuestraLocalizacion, Excepciones);
  6.  
  7. function MuestraLocalizacion(posicion) {
  8. alert(posicion.coords.latitude);
  9. alert(posicion.coords.longitude);
  10. alert(posicion.coords.accuracy);
  11. }
  12.  
  13. function Excepciones(error) {
  14.    switch (error.code) {
  15.    case error.PERMISSION_DENIED:
  16.       alert('Activa permisos de geolocalizacion');
  17.       break;
  18.    case error.POSITION_UNAVAILABLE:
  19.       alert('Activa localizacion por GPS o Redes .');
  20.       break;
  21.    default:
  22.       alert('ERROR: ' + error.code);
  23.     }
  24.   }</script>
  25. </body>
  26. </html>
  27. [/code]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement