AnsweredAssumed Answered

Stop click event if user clicks on marker

Question asked by colin.stief on Aug 31, 2015
Latest reply on Aug 31, 2015 by colin.stief

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 on


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){
    hover_toggle = true;
parks.on("mouse-out", function(evt){
    hover_toggle = false; });
parks.on("click", function(evt){
    var park_point = evt.graphic;



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?