flex - Google Maps Polyline CLICK Event -


i'm implementing map application. uses google maps api flash. there 1 callback function triggered when map clicked. additionally, there plenty of polylines generated dynamically. polylines have click event listener assigned them. problem when click polyline, map click event triggered @ first , polyline's click event fired.

i can't resolve issue. it's anoying. here code assigns callback map's click event:

map = new map(); map.key = google_map_key; map.addeventlistener(mapmouseevent.click, onmapclicked, true); 

and here code assigns callback function polyline's click event:

var polyline:polyline = new polyline(path); polyline.addeventlistener(mapmouseevent.click, cuttoend); 

i need supress "onmapclicked" function's invocation when click on polyline. "cuttoend" method should invoked.

thanks

map.addeventlistener(mapmouseevent.click, onmapclicked, true); 

you use bubblingphase here (third "true" parameter). means, when click polyline, event "reaches" first map, because it's capturing stage button. set parameter "false", or leave 2 parameters (usecapture "false" default). in end of polyline click handler add event.stoppropagation() method call. make event stop bubbling stage, , won't "reach" map.

udate: if mapmouseevent not bubble can compare event.target , event.currenttarget properties. in polyline click listener equal. may add

 if(event.target != event.currenttarget)     return; 

at beginning of map click listener.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -