Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/11/2013, 01:59
maximog
 
Fecha de Ingreso: octubre-2013
Mensajes: 17
Antigüedad: 10 años, 6 meses
Puntos: 0
Saber si se ha aceptado la geolocalizacion

Buenas que tal estais,

Veran estoy con un codigo que hace la geolocalizacion y funciona bien, la cosa es que necesito saber si el usuario acepta cuando le sale la ventana del navegador para permitir geolocalizacion o no.

He buscado alguna información pero no encuentro nada.

Pego el codigo:
Código Javascript:
Ver original
  1. var conexion;
  2.  
  3.  
  4.  
  5. function crearXMLHttpRequest(){
  6.   var xmlhttp=false;
  7.   try {
  8.     xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  9.   } catch (e) {
  10.     try {
  11.        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  12.     } catch (E) {
  13.       xmlhttp = false;
  14.       }
  15.   }
  16.  
  17.   if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  18.     xmlhttp = new XMLHttpRequest();
  19.   }
  20.   return xmlhttp;
  21. }
  22.  
  23. function consultar()
  24. {
  25.  
  26.  
  27. //function detectar(){
  28. if(geo_position_js.init())
  29. {
  30.     document.getElementById('mapa').innerHTML="Leyendo...";
  31.     geo_position_js.getCurrentPosition(mostra_ubicacion,function(){document.getElementById('mapa').innerHTML="No se puedo detectar la ubicación"},{enableHighAccuracy:true});
  32. }   else    {
  33.     document.getElementById('mapa').innerHTML="La geolocalización no funciona en este navegador.";
  34. }
  35. //}
  36. function mostra_ubicacion(p){
  37. var coords = p.coords.latitude + "," + p.coords.longitude;
  38. document.getElementById('mapa').innerHTML="<p>latitud="+p.coords.latitude.toFixed(7)+" longitud="+p.coords.longitude.toFixed(7) + "</p>";
  39.  
  40.  
  41.  
  42.  
  43.   var latitud = p.coords.latitude.toFixed(7);
  44.   var longitud = p.coords.longitude.toFixed(7);  
  45.     conexion=crearXMLHttpRequest();
  46.     conexion.onreadystatechange = procesarEventos;
  47.     conexion.open('GET', 'geo.php?latitud=' + latitud + '&longitud=' + longitud, true);
  48.     conexion.send(null);
  49. }
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56. }
  57.  
  58. function procesarEventos()
  59. {
  60.  
  61.   var detalles = document.getElementById("resultado");  
  62.  
  63.   if(conexion.readyState == 4)
  64.   {
  65.     detalles.innerHTML = conexion.responseText;    
  66.  
  67.   }
  68.   else
  69.   {
  70.     detalles.innerHTML = '';
  71.   }
  72.  
  73. }

A ver si alguien sabe como se podria hacer esto