Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8562191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:40:41+00:00 2026-06-11T16:40:41+00:00

When a marker is selected, I want it to bounce. When I click on

  • 0

When a marker is selected, I want it to bounce. When I click on another marker, I want the first one to stop bouncing, and the other to then start bouncing.
I assumed that this was achievable by simple doing this

function bindInfoWindow(marker, map, infoWindow, html) {
google.maps.event.addListener(marker, 'click', function() {
 document.getElementById('loc-info').innerHTML = html;
 if (marker.getAnimation() != null) {
marker.setAnimation(null);
} else {
marker.setAnimation(google.maps.Animation.BOUNCE);
}
});
}

Instead, the first marker will continue to bounce until it is clicked again, which I don’t want to happen.
Any thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:40:42+00:00Added an answer on June 11, 2026 at 4:40 pm

    You need to keep track of the “current” marker and set its animation to null before bouncing the new marker and setting it to the “current” marker.

    // track marker that is currently bouncing
    var currentMarker = null;
    
    function bindInfoWindow(marker, map, infoWindow, html) {
        google.maps.event.addListener(marker, 'click', function() {
            document.getElementById('loc-info').innerHTML = html;
            // remove the bounce from the "old" marker
            if (currentMarker) currentMarker.setAnimation(null);
            // set this marker to the currentMarker
            currentMarker = marker;
            // add a bounce to this marker
            marker.setAnimation(google.maps.Animation.BOUNCE);
    
        });
    }
    

    Your previous code is only looking at the marker that was just clicked – if it isn’t clicking (the start state) then you make it bounce. The next click checks to see if it is bouncing (it is), and stops it. You could add the same logic to the code above if you want a second click to stop the bouncing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When a marker is placed, I want to call a PHP function (in another
I want to define letters in a grid and then highlight it on selected
i have a multiple marker Google map, it works fine but i want set
I have a marker on google maps on my website. I want the marker
I have a simple marker annotation for methods (similar to the first example in
On click of a marker, I'm opening an InfoWindow on a Google Map. The
I am trying to make an app that opens android market page of selected
I have a <tr:table value=#{mybean.tableValue} binding=#{mybean.tableBinding}> that i want to show with the selection
I am working on a MVC project that is supposed to have one page
I managed to set marker colors for individual markers { y: 5, marker: {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.