Stop queued click event if another event is fired

المشرف العام

Administrator
طاقم الإدارة
I'm looking for a way to suppress a map click event if some other event has already happened. The application I have created has two primary functions:

  1. Click on marker (park points) --> Brings up information about the park you clicked onOR
  2. Click on the map (outside of a marker) --> Clears the map of all information and graphics and runs a query for parks within the area and spits out a list
Here's what I've got:

var hover_toggle = false; ... // Map event handlers click_event = map.on("click", function(evt){ if (hover_toggle == false) { var point = evt.mapPoint; var graphic = evt.graphic; parkQuery(point, graphic); } }); // Marker event handlers parks.on("mouse-over", function(evt){ map.setMapCursor("pointer"); hover_toggle = true; }); parks.on("mouse-out", function(evt){ map.setMapCursor("default"); hover_toggle = false; }); parks.on("click", function(evt){ var park_point = evt.graphic; parkZoom(park_point) }); ... This has it so that whenever a user is hovered over a marker, the hover_toggle makes it so the map.on("click") event is suppressed. However, this doesn't always work... sometimes the marker event fires (it seems to always happen first), and then the map event fires and clears the information the user brings up.

Any ideas on how to suppress or disconnect/connect the map.on("click") event if the marker event is fired at the same time?



أكثر...
 
أعلى