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
Answer
- Could be a bug. Might want to contact support. You can work around it with code though.
- 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
No comments:
Post a Comment