The key is to install the animation only when it is not already installed, like:
google.maps.event.addListener(marker, 'mouseover', function() { if (this.getAnimation() == null || typeof this.getAnimation() === 'undefined') { clearTimeout(bounceTimer); var that = this; bounceTimer = setTimeout(function(){ that.setAnimation(google.maps.Animation.BOUNCE); }, 500); } }); google.maps.event.addListener(marker, 'mouseout', function() { if (this.getAnimation() != null) { this.setAnimation(null); }
I created a JS script for you.
Edited by:
Using the marker as draggable: false seems to break functionality, so if you want the animation to still work, you need to add optimized: false as well, updating my script to contain it. I also saw that there is an error if the marker animation switches too quickly and exits, adds a small timer to indicate before we start the bounce animation, it seems to fix the problem.
source share