Select to view content in your preferred language

ArcGIS JS 4.6 StreamLayer Graphics Array Access

594
1
Jump to solution
02-28-2018 02:53 PM
DanaConway
Emerging Contributor

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

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?

0 Kudos
1 Solution

Accepted Solutions
DanaConway
Emerging Contributor

I spoke with ESRI and they confirmed that layerView.graphics.removeAll() throws an error in version 4.6 of the API.  It is fixed in the in-progress 4.7 API, but since that is not released yet, they said to use layerView.controller.graphics.removeAll();

View solution in original post

1 Reply
DanaConway
Emerging Contributor

I spoke with ESRI and they confirmed that layerView.graphics.removeAll() throws an error in version 4.6 of the API.  It is fixed in the in-progress 4.7 API, but since that is not released yet, they said to use layerView.controller.graphics.removeAll();