Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/07/2013, 11:34
carlosuc99
 
Fecha de Ingreso: junio-2011
Mensajes: 342
Antigüedad: 12 años, 10 meses
Puntos: 5
Exclamación Google maps y for PHP

Buenas,

Vuelvo a las andadas. Despues de un tiempo sin errores me encuentro con esto:

este es mi código:

Código PHP:
Ver original
  1. <?php
  2. //Conexion db
  3.  
  4. $query = mysql_query("SELECT * FROM routes");
  5.  
  6. ?>
  7. <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
  8. <style type="text/css">
  9.   html { height: 100% }
  10.   body { height: 100%; margin: 0px; padding: 0px }
  11.   #map_canvas { height: 100% }
  12. </style>
  13. <script type="text/javascript"
  14.     src="http://maps.google.com/maps/api/js?sensor=false&amp;language=es">
  15. </script>
  16. <script type="text/javascript">
  17.  
  18.  
  19. window.onload = function () {
  20.   var options = {
  21.     zoom: 5,
  22.     center: new google.maps.LatLng(40.84706, -2.944336),
  23.     mapTypeId: google.maps.MapTypeId.ROADMAP
  24.   };
  25.  
  26.   map = new google.maps.Map(document.getElementById('map_canvas'), options);
  27.  
  28.  
  29.   <?php
  30.         for($i = 0; $i < mysql_num_rows($query); $i++){
  31.             $icao = mysql_result($query, $i, 'from');
  32.             $query = mysql_query("SELECT * FROM airports WHERE icao='$icao'");
  33.             $latitude = mysql_result($query, 0, 'latitude');
  34.             $longitude = mysql_result($query, 0, 'longitude');
  35.             $city = mysql_result($query, 0, 'city');
  36.         ?>
  37.   var Airport1 = '<h3 align="center" style="font-family:Arial, Helvetica, sans-serif"><?php echo $icao; ?> - <?php echo $city; ?></h3>';
  38.   var image = 'http://i46.tinypic.com/33zbm09.png';
  39.   var latLonCenter = new google.maps.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>);
  40.   marker = new google.maps.Marker({
  41.     position: latLonCenter,
  42.     map: map,
  43.     draggable: false,
  44.     icon: image,
  45.     title: '<?php echo $icao; ?> - <?php echo $city; ?>',
  46.     Airport1: Airport1
  47.   });
  48.  
  49.  
  50.    
  51.     var infowindow = new google.maps.InfoWindow({
  52.     content: Airport1
  53.     });
  54.  
  55.  
  56.     google.maps.event.addListener(marker, 'click', function () {
  57.       var n = 1;
  58.       var infowindow = new google.maps.InfoWindow({
  59.         content: "",
  60.         maxWidth: 320,  
  61.         zIndex: n
  62.       });
  63.      
  64.       infowindow.setContent(this.Airport1);
  65.       infowindow.setZIndex(n++);  // superpone el último infowindows
  66.       infowindow.open(map, this);
  67.     });
  68.    
  69.     <?php
  70.     $query = mysql_query("SELECT * FROM routes WHERE from='$icao'");
  71.    
  72.    
  73.     for($i = 0; $i < mysql_num_rows($query); $i++){
  74.     $destination = mysql_result($query, $i, 'to');
  75.     $query = mysql_query("SELECT * FROM airports WHERE icao='$destiantion'");
  76.     $latitudeD = mysql_result($query, 0, 'latitude');
  77.     $longitudeD = mysql_result($query, 0, 'longitude');
  78.     ?>
  79.    
  80.     var PolyLine = new google.maps.Polyline({
  81.         strokeColor: "#FF0000",
  82.         strokeOpacity: 2.0,
  83.         strokeWeight: 2
  84.     });
  85.  
  86.     var polyCords = [
  87.     new google.maps.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>),
  88.     new google.maps.LatLng(<?php echo $latitudeD; ?>, <?php echo $longitudeD; ?>)
  89.     ];
  90.    
  91.  
  92.     google.maps.event.addListener(marker, 'click', function() {
  93.  
  94.  
  95.     PolyLine.setPath(polyCords);
  96.  
  97.     PolyLine.setMap(map);
  98.     });
  99.  
  100. <?php } } ?>
  101.  
  102.  
  103.  
  104. }
  105. </script>
  106.   </head>
  107.  
  108.   <body>
  109.     <center><div id="map_canvas" style="width:850px; height:560px;"></div></center>
  110.   </body>

Lo que pasa es que no me muestra las polilyne . Al pulsar en el marker que se abra una red de polylines hacia otros marker. Los marker se muestran sin problemas pero al pulsar en ellos los polylines no aparecen.

La idea es hacer algo como este mapa: http://www.ibe-va.com/index.php?opti...mid=90&lang=en