Select to view content in your preferred language

Removing individual graphic on a view not working in ArcGIS API for JavaScript v4.24

394
1
09-20-2022 05:21 AM
NorbertByiringiro
New Contributor II

Hello folks, 

Can any one help me figure out why view.graphics.remove(pointGraphic) does not work; until i remove all             view.graphics.removeAll(); yet I want to remove only pointGraphic not any other of the added graphics.

 

 const pointGraphic = new Graphic({
      geometry,
      symbol: {
        type: "point-3d",  // autocasts as new PointSymbol3D()
        symbolLayers: [{
          type: "object",  // autocasts as new ObjectSymbol3DLayer()
          width: 50,    // diameter of the object from east to west in meters
          height: 50,  // height of object in meters
          depth: 50,   // diameter of the object from north to south in meters
          resource: { primitive: "sphere" },
          material: { color: "red" }
        }],
        scale:0.5
      },
   
    });
 
   view.graphics.remove(pointGraphic);  
 
I actually want to remove it before I add a new one of the same type, to avoid the redundancy.
 
Thank you for your help
0 Kudos
1 Reply
UndralBatsukh
Esri Regular Contributor

Hi there, 

The view.graphics.remove(graphic) should work without any issues as we don't have any known issues for this. If it is not working, can you please provide a simple reproducible case? 

Here is a very simple test case showing that it works: https://codepen.io/pen?&editors=100

0 Kudos