Ver Mensaje Individual
  #4 (permalink)  
Antiguo 26/09/2012, 10:24
Avatar de Dradi7
Dradi7
 
Fecha de Ingreso: junio-2008
Ubicación: Peru - Lima
Mensajes: 1.518
Antigüedad: 16 años, 9 meses
Puntos: 220
Respuesta: Error de javascript en geolocalizacion - aplicativo web

mira asi debe quedar tu codigo

Código Javascript:
Ver original
  1. <html>
  2. <head>
  3. <meta name = "viewport" content = "width = device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=no;">     
  4. <script src="js/gears_init.js" type="text/javascript" charset="utf-8"></script>
  5. <script src="js/geo.js" type="text/javascript" charset="utf-8"></script>
  6. <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
  7.  
  8. <script>
  9.     function initialize_map()
  10.     {
  11.         var myOptions = {
  12.               zoom: 15,
  13.               mapTypeControl: true,
  14.               mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
  15.               navigationControl: true,
  16.               navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
  17.               mapTypeId: google.maps.MapTypeId.ROADMAP      
  18.         }  
  19.         map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  20.     }
  21.    
  22.     function initialize()
  23.     {
  24.         if(geo_position_js.init())
  25.         {
  26.             document.getElementById('current').innerHTML="Recibiendo Información...";
  27.             geo_position_js.getCurrentPosition(show_position,function(){document.getElementById('current').innerHTML="No puede ubicar posición"},{enableHighAccuracy:true});
  28.         }
  29.         else
  30.         {
  31.             document.getElementById('current').innerHTML="Funcionalidad no disponible";
  32.         }
  33.     }
  34.  
  35.     function show_position(p)
  36.     {
  37.         document.getElementById('current').innerHTML="Latitud= "+p.coords.latitude.toFixed(2)+" Longitud= "+p.coords.longitude.toFixed(2);
  38.         var pos=new google.maps.LatLng(p.coords.latitude,p.coords.longitude);
  39.         map.setCenter(pos);
  40.         map.setZoom(16);
  41.    
  42.         var infowindow = new google.maps.InfoWindow({
  43.             content: "<table>" +
  44.                      "<tr><td></td></tr>" +
  45.                      "<tr><td>Nombre:</td> <td><input type='text' id='name' value='Juan Gomez' readonly='readonly'/> </td> </tr>" +
  46.                      "<tr><td>Dirección:</td> <td><input type='text' id='address'/></td> </tr>" +
  47.                      "<tr><td>Opción:</td> <td><select id='type'>" +
  48.                      "<option value='Opcion 1' SELECTED>Opción 1</option>" +
  49.                      "<option value='Opción 2'>Opción 2</option>" +
  50.                      "<option value='Opción 3'>Opción 3</option>" +
  51.                      "</select> </td></tr>" +
  52.                      "<tr><td></td><td><input type='button' value='Guardar' onclick='saveData()'/></td></tr>"
  53.         });
  54.     }
  55.  
  56.     function saveData() {
  57.       var name = escape(document.getElementById("name").value);
  58.       var address = escape(document.getElementById("address").value);
  59.       var type = document.getElementById("type").value;
  60.       var latlng = marker.getPosition();
  61.  
  62.       var url = "phpsqlinfo_addrow.php?name=" + name + "&address=" + address +
  63.                 "&type=" + type + "&lat=" + latlng.lat() + "&lng=" + latlng.lng();
  64.       downloadUrl(url, function(data, responseCode) {
  65.         if (responseCode == 200 && data.length <= 1) {
  66.           infowindow.close();
  67.           document.getElementById("message").innerHTML = "Ubicación Guardada.";
  68.         }
  69.       });
  70.     }
  71.    
  72.     function downloadUrl(url, callback) {
  73.       var request = window.ActiveXObject ?
  74.           new ActiveXObject('Microsoft.XMLHTTP') :
  75.           new XMLHttpRequest;
  76.  
  77.       request.onreadystatechange = function() {
  78.         if (request.readyState == 4) {
  79.           request.onreadystatechange = doNothing;
  80.           callback(request.responseText, request.status);
  81.         }
  82.       };
  83.  
  84.       request.open('GET', url, true);
  85.       request.send(null);
  86.     }
  87.  
  88.     function doNothing() {}
  89.  
  90.     var marker = new google.maps.Marker({
  91.         position: pos,
  92.         map: map,
  93.         title:"Usted está Aquí"
  94.     });
  95.  
  96.     google.maps.event.addListener(marker, 'click', function() {
  97.       infowindow.open(map,marker);
  98.     });
  99.    
  100. }
  101. </script >
  102. <style>
  103.     body {
  104.     font-family: Arial, Helvetica, sans-serif;
  105.     font-size:10pt;
  106.     padding:0px;
  107.     margin:0px;
  108.     font-style: normal;
  109.     line-height: normal;
  110.     font-weight: normal;
  111.     font-variant: normal;
  112.     color: #333;
  113. }
  114.     #title {
  115.     background-color:#0066CC;
  116.     padding:5px;
  117.     font-family: Arial, Helvetica, sans-serif;
  118.     font-size: 10pt;
  119.     font-style: normal;
  120.     line-height: normal;
  121.     font-weight: normal;
  122.     font-variant: normal;
  123.     color: #FFF;
  124. }
  125.     #current {
  126.     font-size:10pt;
  127.     padding:5px;
  128.     font-family: Arial, Helvetica, sans-serif;
  129.     font-style: normal;
  130.     line-height: normal;
  131.     font-weight: normal;
  132.     font-variant: normal;
  133.     color: #333;
  134. }  
  135. </style>
  136. </head>
  137. <body onLoad="initialize_map();initialize()">
  138.     <div id="title"><strong>Mostrar Posición en el Mapa</strong></div>
  139.     <div id="current">Inicializando...</div>
  140.     <div id="map_canvas" style="width:320px; height:350px"></div>
  141.     <div id="message"></div>
  142. </body>
  143. </html>
__________________
La clave de todo triunfador es eliminar todas sus excusas y sus limitaciones