Select to view content in your preferred language

Custom Widget 1.1 Feature Layer getSelectedFeatures zero count

5872
11
Jump to solution
06-08-2015 12:57 PM
JasonHaught
Deactivated User

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

//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.

0 Kudos
11 Replies
Jianxia
Esri Regular Contributor

Jason,

In response to your related note, you can always add a group of services from feature server or add individual service with a number. This has not been changed at all.

Kelly Hutchins​ for JSAPI issue.

0 Kudos
JasonHaught
Deactivated User

Thank you for clarifying.

0 Kudos