hbostic

popup setFeatures returns null

Discussion created by hbostic on Sep 5, 2013
Latest reply on Sep 5, 2013 by khutchins-esristaff
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);
                    pointLayers.push(deferred);

                    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);
                
            });

Outcomes