views:

514

answers:

1

By default Google Maps Flash API cancels bubbling of all MouseEvents that occur over their Markers (dragable at least). However in MapMouseEvent constructor I see that it has a parameter "bubbles?" so I guess they can be made to bubble mouse events? Is there a way to turn bubbling of mouse events on?

var __marker = new Marker(new LatLng(20, 20), 
    new MarkerOptions({
            draggable: true,
            tooltip:'Drag me'
        }));
    __map.addOverlay(__marker);
A: 

Hi,

Sorry, but I haven't tested the new Google Maps API in Flash. As far as I remember, you could assign listeners to markers, so if by default bubbling is disabled, in theory all you need to do is listen for the event you want for all of the markers you have and when the event listener is triggered you dispatch you own custom event with all the data you need in that handler, and set bubbling to true as well.

e.g.

//assuming SomeGoogleMarkerEvent is a Google Marker Event :)
//and CustomMarkerEvent is a subclass of Event (or another subclass of it )


function markerHandler(event:SomeGoogleMarkerEvent):void{
var customEvent:CustomMarkerEvent = new CustomMarkerEvent();
customEvent.marker = event.target;
dispatchEvent(customEvent,true);
}

The second parameter that I've set to true in the dispatchEvent call is bubbling. Remember, though, that only DisplayObjects' events bubble. There are a lot of resources on Event Dispatching, but I easily forget about DisplayObjects and bubbling.

Hope it helps!

George Profenza