
10/11/2012, 11:43
|
| | Fecha de Ingreso: junio-2011
Mensajes: 342
Antigüedad: 13 años, 7 meses Puntos: 5 | |
Respuesta: For PHP en API Google Maps Cita:
Iniciado por rolygc leete la documentacion de la api para ke la entiendas mejor, el codigo ke te he dejado funciona correctamente porke ya lo he probado antes de enviartelo
[url]https://developers.google.com/maps/documentation/javascript/tutorial?hl=es[/url]
PD: no te hace falta cargar en el body del HTML con el onload porke ya en el javascript te habia puesto window.onload = function() ke lo ke hace es cargar esta funcion una vez terminada de cargar la pagina en el navegador. Por lo ke volverlo a cargar con el <body onload="initialize()"> es una redundancia por lo tanto mala eficiencia de tu codigo etc etc, y eso no tiene nada ke ver con la api de google es javascript basico Esto así no va:
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&language=es">
</script>
<script type="text/javascript">
function initialize() {
(function()
{
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]['Lan']; ?>;
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:650px; height:360px;"></div></center>
</body>
Te agradecería que me ayudaras, porque seguro que lo aplico mal!
Última edición por carlosuc99; 10/11/2012 a las 11:50 |