function executeIdentify (loadedServices, evt) { dojo.forEach(loadedServices, function(service) { if (service.visibleLayers.length > 0) { expected_callback_counter++; //every visible layer should produce a callback, even if no results } } ); //for each loaded non-base layer service dojo.forEach(loadedServices, function(service) { //get service object if (service.visibleLayers.length > 0 && service.visible) { //does service have visible layers? //showLoading(); url = service.url; //get url of service identifyTask = new esri.tasks.IdentifyTask(url); //ceate new identify task identifyParams.layerIds = service.visibleLayers; //set layers to identify identifyTask.execute(identifyParams, function(idResults) { //callback function - fires for each visible layer if (idResults.length > 0) { dojo.forEach(idResults, function(result) { allResults.push(result); } ); } callback_counter++; //a callback has fired - count them if (callback_counter === expected_callback_counter) { if (allResults.length > 0) { //may have no results across all services var content = ""; var currentLayerName; for (var index = 0; index < allResults.length; index++) { content += "<b>" + htmlEncode(allResults[index].layerName) + "</b><br>" content += "<table>"; for (var member in allResults[index].feature.attributes) { content += "<tr><td>" + htmlEncode(member) + ":</td><td>" + htmlEncode(allResults[index].feature.attributes[member]) + "</td></tr>"; } content += "</table><br>"; } var resultText; if (allResults.length === 1) { resultText = " Feature Identified"; } else { resultText = " Features Identified"; } map.infoWindow.setTitle(allResults.length + resultText); map.infoWindow.setContent(content); map.infoWindow.resize(320, 250); map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint)); } else { alert('No results found!'); } } }, //error callback function(err) {console.log("doIdentify: (" + err.name + ") " + err.message);} ) } } ) };
Solved! Go to Solution.
I will try and parse this and then refactor to take this approach. Perhaps a sample for both query and identify at 2.7? Thanks.
We will likely stick with showing multiple query tasks because multiple identify tasks is essentially the same. The difference would be in what happens in the callback that fires when the deferredList is resolved.