I have a custom overlay class (ImageOverlay) which inherits from google.maps.OverlayView. I want it to respond to Google Maps click events (not just DOM click events) but simply using addListener doesn’t seem to do the trick.
e.g. I have a shapes array which contains a mixture of google.maps.Polygon and ImageOverlay objects:
for (var i in shapes) {
google.maps.event.addListener(shapes[i], 'click', function(){alert('hi')});
}
Clicking on the polygons triggers an alert but clicking on the custom overlays does nothing.
How do I make Google Maps API treat the overlays as clickable?
Update for v3:
overlayLayerdoesn’t accept mouse events anymore. Add your overlay tooverlayMouseTargetinstead, add the listener, and it should receive mouse events normally.See: http://code.google.com/apis/maps/documentation/javascript/reference.html#MapPanes