AnsweredAssumed Answered

Custom Widget 1.1 Feature Layer getSelectedFeatures zero count

Question asked by jhaught on Jun 8, 2015
Latest reply on Jul 2, 2015 by jhaught

I have recently been working on porting our custom widget from version 1.0 to version 1.1.

 

The same code  was working in 1.0 but no longer seems to respect selected features in 1.1.*

 

//Gets the specific graphicsLayer requested
var layer = this.map.getLayer(this.map.graphicsLayerIds[i]);

//Verify the layer is a feature layer from base type graphics layer
 if (layer.type && layer.type === "Feature Layer")
 {
          var features = layer.getSelectedFeatures();
            //The map shows features selected within a popup, but this code always returns a zero count in 1.1
            var count  = features.length;
}

 

 

Did something change between versions in this code logic?

 

Why would the features.length be zero, but the feature layer popup show features?

 

The Feature Service being used was from an ArcGIS Server version 10.1 SP1.  I switched to using featue services in 10.2 and the issue still remains.

 

Any insight would be appreciated,

 

Jason

 

*On a related note, I noticed the previous WebMap we used in 1.0 would not work at all since the JS API did not recognize the map.graphicsLayerIds.length. The graphicsLayerIds.length was returning a count of zero. After some fiddling around, I discovered the WebMap now required that feature layers be added one by one to the WebMap. You cannot simply just point to the main feature service as previously worked in 1.0. I don't know if this was a change in the AGOL WebMap, the Esri JS API, ArcGIS Server version for Feature services, or some combination of the sort.

Outcomes