marker animation stop when new begins

697 views
Skip to first unread message

wtrekker

unread,
Jul 22, 2011, 10:59:21 AM7/22/11
to Google Maps JavaScript API v3
hey, i have been working on getting markers to bounce when hovering
over a
link to show where on the map.

now it all works well and the map pans to that specific marker that is
bouncing.
However when hovering over the next link the previous one doesn't
stop, which
mean you end up having potentially all your markers jumping.

This is the code i am using

<code>
function highlightMarker(index)
{
for (i=0; i<markers.length; i++)
{
if (i == index)
{
markers[i].setZIndex(10);
map.panTo(markers[i].getPosition());
markers[i].setAnimation(google.maps.Animation.BOUNCE);
markers[i].setIcon('markers/information1.png');

}
</code>


So do i need to set a unique ID for each marker, and if so how
how is that done.

If any one good give me some pointers that can be implemented into the
above code
i would be grateful.

Cheers!
-- Morty

Rossko

unread,
Jul 22, 2011, 3:49:34 PM7/22/11
to Google Maps JavaScript API v3
> If any one good give me some pointers that can be implemented into the
> above code
> i would be grateful.

You probably want to:
Find out how to un-animate your marker
Write your code to remember the current animated marker.
When triggered, first check if a marker is currently animated, and if
so un-animate it.
Finally start the new animation.
Reply all
Reply to author
Forward
0 new messages