Ver Mensaje Individual
  #26 (permalink)  
Antiguo 12/11/2012, 08:32
carlosuc99
 
Fecha de Ingreso: junio-2011
Mensajes: 342
Antigüedad: 12 años, 10 meses
Puntos: 5
Exclamación Respuesta: For PHP en API Google Maps

Ok,

Lo he dejado así:

Código:
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> 
<style type="text/css"> 
  html { height: 100% } 
  body { height: 100%; margin: 0px; padding: 0px } 
  #map_canvas { height: 100% } 
</style> 
<script type="text/javascript" 
    src="http://maps.google.com/maps/api/js?sensor=false&amp;language=es"> 
</script> 
<script type="text/javascript"> 
     
    
(function() 
{
	
	var lat = [], lon = [], icao = [], city = [];
							
	var i = 0;

	<?php if ( mysql_num_rows($query) > 0){
		 for( $c = 0; $c < count($array_query); $c++ ){ ?>
		
			lat[i]  = <?php echo $array_query[$c]['Lan']; ?>;
			lon[i]  = <?php echo $array_query[$c]['Lon']; ?>;
			icao[i] = <?php echo $array_query[$c]['ICAO']; ?>; 
			city[i] = <?php echo $array_query[$c]['City']; ?>;
			i++;

		<?php }; ?>   
	<?php }; ?>
												
	var latLonCenter = new google.maps.LatLng( lat[0], lon[0] );    
						   
	window.onload = function() 
	{
		var options = {
			zoom: 5,
			mapTypeId: google.maps.MapTypeId.ROADMAP
		};

		map = new google.maps.Map(document.getElementById( 'map_canvas' ), options);

		for ( var i = 0; i < lat.length; i++ )
		{
			var latLng = new google.maps.LatLng( lat[c], lon[c] );
			getMarker( latLng, icao[c], city[c] );
		}  

		map.setCenter(latLonCenter);
	}
							
	function getMarker(latLng, icao, city)
	{
		var image = 'http://mapicons.nicolasmollet.com/wp-content/uploads/mapicons/shape-default/color-d22328/shapecolor-color/shadow-1/border-dark/symbolstyle-white/symbolshadowstyle-dark/gradient-no/airport.png'; 
		
		marker = new google.maps.Marker({
			position: latLng,
			map: map,
			draggable: false,
			animation: google.maps.Animation.DROP,
			icon: image,
			title: icao + ' ' + city
		});
	} 
})();


         
        
   

</script> 
</head> 
<body onload="initialize()"> 
    <center><div id="map_canvas" style="width:650px; height:360px;"></div></center> 
</body>
Las consultas a la base de datos van bien.

Los...
Código PHP:
...
        <?php }; ?>   
    <?php }; ?>...
Son para cerrar el if y el for.

De todas maneras como lo he dejado no carga ni el mapa.