Selected features cleared in FeatureLayer after onResume({firstOccurence: true})

Discussion created by lscharen on Jan 31, 2013
Latest reply on Nov 11, 2016 by flspat
I am trying to load an initial set of features into a FeatureLayer immediately after the map and FeatureLayer are loaded via the FeatureLayer.selectFeatures(query) call.

The FeatureLayer has a scale range that is outside of the initial map scale.

The selectFeatures call is successful and the selectedFeatures property has the list of features.  However, once the map is zoomed in past the scale range threshold, the FeatureLayer's resume() method is called from evaluateSuspension() method with evt.firstOccurence = true.  I don't quite follow the flow of events after this point, but presumably, calling the initialize() method on the layer._mode object clears out any selected features.

The end result is that selected features are cleared from the FeatureLayer and do not display on the map.

I've worked around the issue by calling the private FeatureLayer._resume() and FeatureLayer._suspend() methods from my onLoad event handler but before I call the initial selectFeatures().  This works, but I'd like to avoid calling internal methods.

Also, calling the non-private resume() and suspend() methods do not work because the Layer.canResume() function always returns false because this.visibleAtMapScale is false.

Any suggestions on how to perform a initial selectFeature() on a FeatureLayer?