Ver Mensaje Individual
  #19 (permalink)  
Antiguo 10/11/2012, 03:28
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

Cita:
Iniciado por rolygc Ver Mensaje
kieres infoWindow crealo y agregalo a ese codigo ke te he dejado....
He dejado el mapa 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 initialize() {
	
	 var Destinos = {
      autozoom: true,
      zoom: 5,
      center: new google.maps.LatLng(40.84706, -2.944336),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    
    var map = new google.maps.Map(document.getElementById("map_canvas"), Destinos);
    
	var lat = [], lon = [], icao = [], city = [];
							
	var i = 0;

	<?php if ( mysql_num_rows($query) > 0): ?> 
		<?php while ( $row = mysql_fetch_assoc($query) ): ?>
		
			lat[i]  = <?php echo $lat[$c]['Lat']; ?>;
			lon[i]  = <?php echo $lon[$c]['Lon']; ?>;
			icao[i] = <?php echo $lat[$c]['ICAO']; ?>; 
			city[i] = <?php echo $lat[$c]['CITY']; ?>;
			i++;

		<?php endwhile; ?>   
	<?php endif; ?>
												
	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:950px; height:660px;"></div></center>
</body>
No funciona. Todavía no le he puesto el InfoWindow pero el $query funciona.
Lo que a lo mejor falla es porque las variable $city y $icao no tienen nada que ver con la localización, sólo son varables de texto ej: $city = Vigo & $icao = LEVX.