arcgis api for javascript 4.x, 删除绘制的点、线、面

发布时间 2023-09-19 09:15:26作者: ZerlinM

1、在视图mapView 上添加的点线面

// 删除所有
mapView.graphics.removeAll();

// 删除一个
const pointGraphic = new Graphic({geometry, symbol})
mapView.graphics.remove(pointGraphic);

// 删除多个
mapView.graphics.removeMany([pointGraphic, polylineGraphic]);

2、GraphicsLayer图层上的点线面

const pointGraphicLayer= new GraphicsLayer();  // 图层

// 删除所有
pointGraphicLayer.removeAll();

// 删除一个
const pointGraphic = new Graphic({geometry, symbol})
pointGraphicLayer.remove(pointGraphic);

// 删除多个
pointGraphicLayer.removeMany([pointGraphic, polylineGraphic]);