AnsweredAssumed Answered

ArcGIS JS 4.6 StreamLayer Graphics Array Access

Question asked by dana.conway on Feb 28, 2018
Latest reply on Mar 1, 2018 by dana.conway

Using the ArcGIS JS 4.4 API, I was able to access a StreamLayer's graphics with this snippet (in this case, I'm removing the graphics):

mapView.whenLayerView(streamLayer)

   .then(function(layerView){

      layerView.graphics.removeAll(); 

});

We have upgraded to the 4.6 API.   The documentation states that you can still access it that way, but layerView.graphics is undefined when you examine it in the debugger, and the graphics are not being removed from the layerhttps://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-StreamLayerView.html#graphics 

I realize that I can use the queryGraphics method, but I was unsuccessful in removing the graphics from the layer in this manner.

mapView.whenLayerView(streamLayer)

   .then(function(layerView){

      layerView.queryGraphics().then( function(graphics) {

      console.log(“Num graphics: “ + graphics.length);

      graphics.removeAll();   // DOES NOT WORK

   });

});

 

Using the browser debugger to examine the properties in the layerView, I saw that there were 2 options that ended up working to clear the graphics.  But, these 2 properties are not mentioned in the documentation, so I'm not quite sure what they are supposed to be used for.   These two were:  layerView.featuresView.graphics.removeAll();  and layerView.controller.graphics.removeAll();

 

Does anyone know the correct way to access the StreamLayer's graphics array in the 4.6 API?   Are either of these acceptable?

Outcomes