Identify with Layer Toggling

660
2
07-28-2011 02:03 PM
MikeLong
New Contributor III
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 on StackExchange here.
http://gis.stackexchange.com/questions/12772/identify-with-layer-toggling
0 Kudos
2 Replies
HemingZhu
Occasional Contributor III
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 on StackExchange here. 
http://gis.stackexchange.com/questions/12772/identify-with-layer-toggling


 function executeIdentifyTask(evt) {
       if (dynlayer.visibleLayers.length <1)
             return;        
        identifyParams.geometry = evt.mapPoint;
        identifyParams.mapExtent = map.extent;
       
        var deferred = identifyTask.execute(identifyParams);
 
        deferred.addCallback(function(response) {     
          // response is an array of identify result objects    
          // Let's return an array of features.
          return dojo.map(response, function(result) {
            var feature = result.feature;
            feature.attributes.layerName = result.layerName;
            
              //console.log(feature.attributes.NAME);
              var template = new esri.dijit.PopupTemplate({ title: "Name: {NAME}", 
     fieldInfos: [
      {fieldName: "ADDRESS", visible: true, label: "Address:"}
    
    ]
     });
              feature.setInfoTemplate(template);
            
            return feature;
          });
        });
 
      
        // InfoWindow expects an array of features from each deferred
        // object that you pass. If the response from the task execution 
        // above is not an array of features, then you need to add a callback
        // like the one above to post-process the response and return an
        // array of features.
        map.infoWindow.setFeatures([ deferred ]);
        map.infoWindow.show(evt.mapPoint);
      }

0 Kudos
derekswingley1
Frequent Contributor
0 Kudos