Marker covered by a custom overlay still receives mouseover

526 views
Skip to first unread message

sgiddings

unread,
May 5, 2011, 11:22:57 AM5/5/11
to Google Maps JavaScript API v3
Here's my context -
I have a custom information window implemented with a custom overlay
(OverlayView).
As usual, when the marker is clicked, the custom information window is
displayed.
At times, it will cover other markers.

In addition, I have a custom tooltip on the marker which is triggered
with the mouseover/mouseout mouse events.

My problem is that, even though the custom overlay (html dom object)
covers the marker, the marker will still receive the mouseover/
mouseout mouse events. This is still the case if I try to stop
bubbling.

However, if I capture the click event and stop bubbling in the custom
overlay, it will not be passed through to the underlying marker.

This applies to firefox and ie.

Is this a known issue/bug ?

sgiddings

unread,
May 5, 2011, 12:33:20 PM5/5/11
to google-map...@googlegroups.com
I omitted to mention that I put the custom overlay in the floatPane.

sgiddings

unread,
May 7, 2011, 7:12:37 AM5/7/11
to google-map...@googlegroups.com
Ok, after further investigation, this does not happen with the standard infowindow.
So, there would appear to be something being done by the standard infowindow which blocks the mouseover event getting to underlying markers.

What is being done ?

sgiddings

unread,
May 7, 2011, 12:33:27 PM5/7/11
to google-map...@googlegroups.com
Well !!!
Considering the extensive interest that this subject has provoked, here is the solution to this problem (if anyone really cares).

It is necessary to capture the following mouse events in the custom overlay info window -
- mouseover
- mousemove
- mousedown
- mouseup
- click
The capture needs to be on the outer container (usually a div).

Your cancel bubble code should call (if defined) -
- preventDefault()
- stopPropagation()
and set
- window.event.cancelBubble = true;
- e.cancelBubble = true;
and return
- false

There you go!  Happy debugging

Esa

unread,
May 7, 2011, 4:25:06 PM5/7/11
to Google Maps JavaScript API v3
Thanks that you share the valuable information though your question
didn't provoke much discussion. Silence often means that listeners are
listening.

I finally found the thread from 2009 where the question was discussed
http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/ef6e8e2942421bab/ff3739505eb833df

It is still worth having a look. You can find that you don't have to
care about window.event if you use addDomListener()
Reply all
Reply to author
Forward
0 new messages