Select to view content in your preferred language

How to clear/remove all features from FeatureLayer

264
3
Jump to solution
08-20-2024 11:16 AM
ForrestLin
Frequent Contributor

Is it the right approach to clear/remove all features from FeatureLayer and update FeatureTable?

  clear(): void {
    featureLayer.queryFeatures().then(featureSet => {
        const edits = {
          deleteFeatures: featureSet.features
        };
        featureLayer.applyEdits(edits)
          .then(editsResult => {
            featureTable.refresh();
          });
    });
  }
Tags (1)
0 Kudos
1 Solution

Accepted Solutions
UndralBatsukh
Esri Regular Contributor

Yes it is. The codepen I provided in the other discussion shows this approach.

 

Here is the codepen: https://codepen.io/U_B_U/pen/PorRwbM

View solution in original post

0 Kudos
3 Replies
UndralBatsukh
Esri Regular Contributor

Yes it is. The codepen I provided in the other discussion shows this approach.

 

Here is the codepen: https://codepen.io/U_B_U/pen/PorRwbM

0 Kudos
UndralBatsukh
Esri Regular Contributor

Reread your question again. Yes your approach delete all features from the layer and clear the table.

0 Kudos
ForrestLin
Frequent Contributor

@UndralBatsukh 

Thanks.

0 Kudos