popup setFeatures returns null

09-05-2013 05:36 AM
Occasional Contributor II
Hello, I am trying to build an array of deferreds and pass that to the popup setFeatures function.
I have verified that my deferreds are returning properly because this line gets called each time
log("maquery p window", queryResults, false);

However when I do this
queryDeferred = esriMap.infoWindow.setFeatures(pointLayers);

queryDeferred is null. 

From the documentation https://developers.arcgis.com/en/javascript/jsapi/popup-amd.html#onsetfeatures

I thought I would get an array of deferreds back, however I get null.  Below is the code, hopefully someone can point out what I am doing wrong

$.each(layers, function (index, layer) {

                if (layer.featureCollection) {
                    layerObject = layer.featureCollection.layers[0].layerObject;
                else {
                    layerObject = layer.layerObject;

                if (layerObject && layerObject.geometryType === 'esriGeometryPoint') {//only search the point features
                    var query = new Query();
                    query.geometry = bufferResults[0];
                    query.outFields = [layerObject.objectIdField]

                    var deferred = layerObject.queryFeatures(query);

                    deferred.addCallback(function (queryResults) {
                        log("maquery p window", queryResults, false);
                    //queryDefferred = esriMap.infoWindow.setFeatures(layerObject.queryFeatures(query));


             //should be an array of deferreds, I think
            queryDeferred = esriMap.infoWindow.setFeatures(pointLayers);
            //I will doing something different below if I got my array back
            queryDefferred.addCallback(function (queryResults) {
                log("query all", queryResults, false);

            queryDefferred.addErrback(function (error) {
                log("Query failed: ", dojo.toJson(error), true);
0 Kudos
1 Reply
Esri Frequent Contributor
Looks like we have a documentation issue with the Popup setFeatures method. SetFeatures doesn't return an array of deferreds or graphics. Instead you'll want to listen for the set-features event. This event fires when:

  • The setFeatures method is called with an array of features

  • The setFeatures method is called with an array of deferreds and all the deferreds have completed. If clearFeatures is called before the pending deferreds have completed this event will not fire.

0 Kudos