Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set animation google maps marker

well im trying to set the BOUNCE animation to a specific marker but whenever i call the marker.setAnimation(google.maps.Animation.BOUNCE) method console says "Cannot read property 'BOUNCE' of undefined" this means that marker is not defined right? but if I use marker.setTitle('Bouncing') the title does change. am i doing something wrong , here is the code

   <script type="text/javascript">
        function addMarker(lat,lng,img,title,bounce)
        {
         var myLatLng = new google.maps.LatLng(lat, lng);

        var marker = new google.maps.Marker({
                position: myLatLng,
                map: map,
                icon: img,
            title: title,
            zIndex: 1
            });

            if(bounce=='set'){marker.setAnimation(google.maps.Animation.BOUNCE);
            marker.setTitle('Bouncing');};

        }
    </script>

php script

    for($i=0;$i<count($losDatos);$i++)
    {

    $utc=new DateTime($losDatos[$i]['fechaUtc']);
    $utc->modify('-'.horarioVerano().' hours');
    echo $utc->format("Y-m-d H:i:s");
    if($losDatos[$i]['camion']==$camion)
    {
    $script.="addMarker(".$losDatos[$i]['latitud'].",".$losDatos[$i]['longitud'].",".$losDatos[$i]['img'].",".$losDatos[$i]['nombre'].",'set');";
    }else
    {
       $script.="addMarker(".$losDatos[$i]['latitud'].",".$losDatos[$i]['longitud'].",".$losDatos[$i]['img'].",".$losDatos[$i]['nombre'].");";
    }

    }

echo $script;
like image 567
Gustavo Avatar asked Mar 18 '11 19:03

Gustavo


Video Answer


1 Answers

try:

marker.setAnimation(google.maps.Animation.BOUNCE)
like image 197
Pierre Valade Avatar answered Oct 23 '22 02:10

Pierre Valade