Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 3 down vote accepted
  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
share|improve this answer
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 –  blord-castillo Jul 29 '11 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. –  Derek Swingley Jul 29 '11 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? –  Stephen Lead Jul 31 '11 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. –  Derek Swingley Aug 1 '11 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 '11 at 15:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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