AnsweredAssumed Answered

Looking for the right event to hook into for feature deselect

Question asked by evtguy on Aug 8, 2014
Latest reply on Aug 11, 2014 by evtguy

I'm currently developing a basic web map app for showing various projects. I'm using v3.10 of the API and started with the "Popup content in side panel" sample. Instead of a static side panel for a selected feature's information, I decided to use a jQuery slide panel that appears when the user clicks on a feature (see the screenshot). I have added a close button within my slide panel which will close the panel and fire map.graphics.clear() to remove the graphic of the currently selected item. This all works just fine.

 

What I want to do (can can't figure out the best way to do it) is close my side panel if the user clicks someplace on the map (but not on another feature). I tried to account for this using the following:

map.on("click", function() {
     if(map.graphics.graphics.length == 0) {
          //Close my side panel here
     }
}

but the problem is that the click event fires before the selected graphic is removed and so map.graphics.graphics.length never equals zero. I've also thought about trying to tie into the map's graphicLayer and it's "graphics-clear" event but I can't seem to do it. The following returns null:

theGraphicsLayer = map.graphics;

So what am I missing? The app isn't public facing yet so I can't link to a live example.

 

Thanks!

Steve

 

Screenshot:

tipMapFeatSelect.jpg

Outcomes