0

I have the following code that makes a clicked marker bounce on a Google map.

However, Im not sure how to stop the animation after say 2 seconds. Must be some kind of timer function that I can set?

Here is the code:

 google.maps.event.addListener(marker, 'click', function()  
   {  
    map.setCenter(marker.getPosition());  
    map.setZoom(17);   

    if(marker.getAnimation() != null)   
        {  
            marker.setAnimation(null);  
        }  
    else  
        {  
            marker.setAnimation(google.maps.Animation.BOUNCE);  

        }  

    } );  

Any suggestions would be great

4

1 回答 1

1
google.maps.event.addListener(marker, 'click', function () {  
    map.setCenter(marker.getPosition());  
    map.setZoom(17);   

    if (marker.getAnimation() != null) {  
        marker.setAnimation(null); 
    } else {  
        marker.setAnimation(google.maps.Animation.BOUNCE);  

        window.setTimeout(
            function() {
                marker.setAnimation(null); 
            },
            2000
        );  
    }  

});  
于 2012-04-20T00:43:03.767 回答