Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/03/2016, 08:05
robertocarrillo
 
Fecha de Ingreso: septiembre-2014
Mensajes: 79
Antigüedad: 9 años, 7 meses
Puntos: 0
marker zoom size

Hola el script que uso me trae varios markers. hasta ahí todo bien, pero.... como hago que al cambiar el zoom cambien de tamaño todos juntos? Ya que de esta forma puedo controlar solamente el último y el resto no cambia al cambiar el zoom. Si alguien me podría ayudar por favor. Muchísimas gracias.
Código PHP:
<?php 
try {require_once "clases/conexion.php";
$conexion Connect();
$query='SELECT dato1,dato2,dato3,dato4,dato5 FROM tabla where campo=dato';
    
$stmt $conexion->prepare($query);
    
$stmt->execute();
    while( 
$datos $stmt->fetch())
    {
    
$dato1[] = $datos["dato1"];
    
$dato2[]=$datos["dato2"];
    
$dato3[]=$datos["dato3"];
    
$dato4[]=$datos["dato4"];    
    
$qw=$datos["dato5"];$we=explode(",",$qw);$lat[]=$we[0];$lng[]=$we[1];
        
$i $i+1;
    }
    
$CantidadDeLineas $i;
?>
<div align="center" id="map1"></div>
    <script type="text/javascript">
    function initMap() {
    var map = new google.maps.Map(document.getElementById('map1'), {
    mapTypeControl: false,
    streetViewControl: false,
    zoom: 15,
    zoomControl: true,
    zoomControlOptions: {
    style: google.maps.ZoomControlStyle.SMALL
    },
    <?php echo "center: {lat:".$lat[0].",lng:".$lng[0]."}"?>
    });
    setMarkers(map);
    }
    var accidentes = [
    <?php
        
for ($i=0$i<$CantidadDeLineas$i++)
        {echo 
$dato1[$i].",".$lat[$i].",".$lng[$i]."],";}?>    ];
    
        function setMarkers(map) {
        var image = new google.maps.MarkerImage(
       'images/img.png',
        new google.maps.Size(30,30), //size
        null, //origin
        null, //anchor
        new google.maps.Size(30,30) //scale
    );
google.maps.event.addListener(map, 'zoom_changed', function() {
zoom=map.getZoom();
if(zoom==21){marker.setIcon(new google.maps.MarkerImage('images/img.png', null, null, null, new google.maps.Size(1900, 1900)));}
if(zoom==20){marker.setIcon(new google.maps.MarkerImage('images/img.png', null, null, null, new google.maps.Size(950, 950)));}
if(zoom==19){marker.setIcon(new google.maps.MarkerImage('images/img.png', null, null, null, new google.maps.Size(550, 550)));}
if(zoom==18){marker.setIcon(new google.maps.MarkerImage('images/img.png', null, null, null, new google.maps.Size(242, 242)));}
if(zoom==17){marker.setIcon(new google.maps.MarkerImage('images/img.png', null, null, null, new google.maps.Size(120, 120)));}
if(zoom==16){marker.setIcon(new google.maps.MarkerImage('images/img.png', null, null, null, new google.maps.Size(61, 61)));}
if(zoom==15){marker.setIcon(new google.maps.MarkerImage('images/img.png', null, null, null, new google.maps.Size(30.5, 30.5)));}
if(zoom==14){marker.setIcon(new google.maps.MarkerImage('images/img.png', null, null, null, new google.maps.Size(15, 15)));}
if(zoom==13){marker.setIcon(new google.maps.MarkerImage('images/img.png', null, null, null, new google.maps.Size(9, 9)));}
if(zoom==12){marker.setIcon(new google.maps.MarkerImage('images/img.png', null, null, null, new google.maps.Size(4, 4)));}
if(zoom==11){marker.setIcon(new google.maps.MarkerImage('images/img.png', null, null, null, new google.maps.Size(1, 1)));}
});

    for (var i = 0; i < accidentes.length; i++) {
    var accidente = accidentes[i];

    var marker = new google.maps.Marker({
    position: {lat: accidente[1], lng: accidente[2]},
    map: map,
    icon: image,
    animation: google.maps.Animation.DROP,
    title: accidente[0]
    });
    }
    }
    </script>

<?php
    
}catch(PDOException $e)    {echo 'Error: ' $e->getMessage();}    $conn=null
?>
</div>

Última edición por robertocarrillo; 09/03/2016 a las 13:09