Ver Mensaje Individual
  #7 (permalink)  
Antiguo 27/07/2012, 13:07
Avatar de kimmy
kimmy
 
Fecha de Ingreso: julio-2008
Mensajes: 841
Antigüedad: 15 años, 9 meses
Puntos: 15
Respuesta: Seleccionar coordenadas, guardar y mostrar google maps

Estoy feliz, ya lo resolví. Era que estaba mal la consulta mysql.

Se los dejo para que lo puedan usar, pues no tuve suerte en las respuestas y se que nos cuesta a algunos.

Este es el código completo:

Código PHP:
Ver original
  1. <?php
  2. include ('func/db.php');
  3.  
  4. $conexion = db_connect();
  5.   if (!$conexion )
  6.    return 0;
  7.    
  8. $rs = mysql_query("SELECT * FROM coordenadas WHERE id='1'");
  9.     while($result=mysql_fetch_array($rs))
  10.     {
  11.     $id = $result['id'];
  12.         $coordenada1 = $result['coordenada1'];
  13.         $coordenada2 = $result['coordenada2'];
  14.        
  15.     }
  16. ?>
  17.  
  18.  
  19. <html>
  20. <head>
  21. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  22. <title>Mapa</title>
  23. <script src="http://maps.google.com/maps?file=api&v=3&key=ABQIAAAAp9wVclPicp2HGB4QNX-LLRTqx4D3bS478d-1w1nVZmw5mBzr_hTd8Hb4lXsLPv7hW7mRH6_tkUmJ3g" type="text/javascript"></script>
  24. <script type="text/javascript">
  25.  
  26. var map      = null;
  27. var geocoder = null;
  28.  
  29. function load() {
  30.  
  31. var coordenada1= "<?php echo $coordenada1; ?>";
  32. var coordenada2= "<?php echo $coordenada2; ?>";
  33.  
  34.  
  35.  map = new GMap2(document.getElementById("map"));
  36.  map.setCenter(new GLatLng(coordenada1,coordenada2), 15);
  37.  map.addControl(new GSmallMapControl());
  38.  map.addControl(new GMapTypeControl());
  39.  geocoder = new GClientGeocoder();
  40.      }
  41.  function showAddress(address, zoom) {
  42.  
  43. if (geocoder) {
  44.           geocoder.getLatLng(address,
  45.              function(point) {
  46.                if (!point) {
  47.                 alert(address + " not found");
  48.                } else {
  49.                 map.setCenter(point, zoom);
  50.                 var marker = new GMarker(point);
  51.                 map.addOverlay(marker);
  52.                 document.form_mapa.coordenadas1.value = point.y;
  53.                 document.form_mapa.coordenadas2.value = point.x;
  54.                   }
  55.  
  56.                 }
  57.  
  58.          );
  59.  
  60.        }}
  61. </script>
  62. </head>
  63.  
  64. <body onLoad="load();"  onunload="GUnload();">
  65. <center>
  66. <div align="center" id="map" style="height: 425px; width: 425px;">
  67. </div>
  68. </center>
  69. </body>
  70. </html>
__________________
Caminando con el corazón partío