I have spent some time reading the numerous threads about setting the identify task to work with layer toggling and I seem to have it working properly except for one small issue. The identify task will continue to work even though all of the layers are turned off. The Pop-Up dialogue will show "searching" for some time, until the JavaScript times out. The more problematic issue is that the task will lock up a SOC process until it times out as well, which is much longer than the JavaScript time out. This gives the user the ability to use the identify task again, repeating the process above, and locking up another SOC process. Since 2 SOC processes are the default this means that the service is useless until one of them times out.

Click below to view an example of this behavior. This is hitting the ArcGIS.com sample server so you will have to take my word on the "hung" SOC processes. http://geoville.org/viewers/identifytoggle/

My question is two fold. 1: Could this be a bug? 2: Any ideas on how to keep the identify task from executing when there are no layers visible?

Thanks for your help.

I have also posted this question in the Esri forums here. http://forums.arcgis.com/threads/35860-Identify-with-Layer-Toggling?p=120915#post120915

1 Answer 1

  1. Could be a bug. Might want to contact support. You can work around it with code though.
  2. Yes. I ended up refactoring your code quite a bit and posted it on JSFiddle: http://jsfiddle.net/swingley/euKZB/

Specific changes:

  • create identify parameters and identify task once
  • update identify parameter's layerIds as layer visibility changes
  • use a global variable to keep track of the event listener for map click
  • disconnect map click listener when no layers are visible
  • connect map click listener if it's not connected when layers are visible
  • removed onclick attributes for your input tags and used dojo.query get the checkboxes and dojo.connect to listen to listen to onclick for check boxes
  • 2
    I made a slight change to Derek's method. Instead of disconnecting and reconnecting the listener, I did a test at the start of the listener to see if there were no visible layers. If there are no visible layers, the request is never sent, the popup features are cleared, and the no results popup is displayed. This way, a popup is still displayed with no results when all layers are off. See jsfiddle.net/blordcastillo/Ddt8V Jul 29, 2011 at 14:20
  • Good call, that works too. I went with the connect/disconnect method as it seemed like a good chance to show what you can do with those two functions. Jul 29, 2011 at 15:00
  • Derek, it looks like there's an appetite for an out-of-the-box Identify plugin which works like the ArcMap identify tool - connect it to your Map object, and it "just works". Is that something you'd be able to influence? Jul 31, 2011 at 23:15
  • @Steve it was done in the past...you can find the widget here: arcscripts.esri.com/details.asp?dbid=16085 Would need to be updated for 2.x though...it might just work with a newer release but I haven't tested it. Aug 1, 2011 at 1:09
  • Thanks Derek and Blord! I agree with Stephen, it would be nice to have an updated identify widget.
    – Mike Long
    Sep 1, 2011 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.