Targeting Info Window X Close to stop Bounce

912 views
Skip to first unread message

Mike Wellman

unread,
Jan 17, 2011, 2:23:17 PM1/17/11
to google-map...@googlegroups.com
Is there any way to target the Info Window x Close button to "drop"/Stop the bouncing animation when the info window is closed?

Code:

<code>
var infowindow = new google.maps.InfoWindow({
    content: contentString
});        
marker = new google.maps.Marker({
    map:map,
    draggable:false,
    animation: google.maps.Animation.DROP,
    title:"Marker 1",
    position: latlng
});
google.maps.event.addListener(marker, 'click', function() {
    infowindow.open(map,marker);
});
google.maps.event.addListener(marker, 'click', toggleBounce);
}
 
/*Set Animation of Marker Bounce*/   
function toggleBounce() {
    if(marker.getAnimation() != null){
      marker.setAnimation(null);
    }else{
      marker.setAnimation(google.maps.Animation.BOUNCE);
    }
}
</code>

Rossko

unread,
Jan 17, 2011, 3:07:20 PM1/17/11
to Google Maps JavaScript API v3
> Is there any way to target the Info Window x Close button to "drop"/Stop the
> bouncing animation when the info window is closed?

Have you looked at the infoWindow events available?
http://code.google.com/apis/maps/documentation/javascript/reference.html#InfoWindow

Mike Wellman

unread,
Jan 17, 2011, 4:51:08 PM1/17/11
to google-map...@googlegroups.com
No and thank you for pointing this out.  I'll check it out.

en4ce

unread,
Jan 17, 2011, 6:55:18 PM1/17/11
to Google Maps JavaScript API v3
might you create a custom infowindow and catch the close function in
it as well...

see this:
http://gmaps-samples-v3.googlecode.com/svn/trunk/infowindow_custom/infowindow-custom.html

within the code:

var closeImg = document.createElement("img");
closeImg.style.width = "32px";
closeImg.style.height = "32px";
closeImg.style.cursor = "pointer";
--> closeImg.onlick = dothisandthat();<--
closeImg.src = "http://gmaps-samples.googlecode.com/svn/trunk/
images/closebigger.gif";
topDiv.appendChild(closeImg);

Mike Wellman

unread,
Jan 20, 2011, 11:12:28 AM1/20/11
to google-map...@googlegroups.com
Thank you but for the moment I'm using:

google.maps.event.addListener(marker, 'click', toggleBounce);

google.maps.event.addListener(infowindow, 'closeclick', function() {
    marker.setAnimation(null);
});

for testing and everything works as planned.

Mike Wellman

unread,
Jan 20, 2011, 12:14:56 PM1/20/11
to google-map...@googlegroups.com
Now to try to figure out how to toggle the bounce with multiple markers

DropaBalm.com Jambo

unread,
Jan 21, 2011, 3:41:39 PM1/21/11
to Google Maps JavaScript API v3
Hi Mike,

On Jan 20, 11:14 am, Mike Wellman <mike.well...@gmail.com> wrote:
> Now to try to figure out how to toggle the bounce with multiple markers

Check out: http://demo.dropabalm.com/storynets/2

You might be interested in this work-in-process involving lots of
bouncing markers used as a cue for navigation and anthropomorphizing
the geo-data to the related 'StoryNet Games' under development. I'm
also just beginning to link Graphviz images and image-maps as an
isomorphic graph view and navigation element (kind of visual sidebar)
to the network displayed geo-location wise on the map.

One thing to note (and I guess I'll need to report this to both Google
map folks and Google Chrome folks) these bouncing markers behave as
expected in virtually all _current_ mainstream browsers EXCEPT Chrome/
Chromium. After toggling a number of these click-able marker, buttons,
image-areas in Chrome, they 'get tired' and stop bouncing. These
markers in all others browsers, however, keep their spunk and like the
'battery bunny' keep going and going...

You can find out about all you need to know about what I'm doing on
this page by using Firebug/Firefox and/or viewing page source. (The
JavaScript on this page is dynamically generated in PHP so there is no
JavaScript source file that I can point you too per se.)

Also, for those who might be interested, this is a Drupal/Ubercart
site so I forked Brad Wedell's PHP GoogleMapAPI class with Javascript
V.3 support to create a Drupal custom module. There is additional info
on this here:

http://www.sohodojo.biz/blogs/jims-tech-blog/googlemapapiv3-module-drupal

I hope this info and demo are useful to you.

--www.DropaBalm.com Jambo--
AKA Jim Salmons
Cedar Rapids, Iowa USA

Mike Wellman

unread,
Jan 25, 2011, 2:26:33 PM1/25/11
to google-map...@googlegroups.com
Thanks Jim,  This gives insight on future functionality (the power of v3) that can be used in my current and future projects.
Reply all
Reply to author
Forward
0 new messages