Select to view content in your preferred language

Issue of Client-Side FeatureLayer: featureLayer.source not updated after calling featureLayer.applyEdits(edits)

213
5
Jump to solution
08-20-2024 06:03 AM
ForrestLin
Frequent Contributor

I update a Client-Side FeatureLayer by calling featureLayer.applyEdits(edits), but featureLayer.source doesn't get updated.

0 Kudos
1 Solution
5 Replies
UndralBatsukh
Esri Regular Contributor

Hi there, 

You cannot use source to get the features that are added or updated once after the client-side feature layer is initialized.  You need to use FeatureLayer.queryFeatures to get the features in your client-side query. 

 

Screenshot 2024-08-20 at 7.13.39 AM.png

0 Kudos
ForrestLin
Frequent Contributor

@UndralBatsukh 

I use FeatureTable with client-side FeatureLayer. FeatureTable is not updated after calling featureLayer.applyEdits(edits).

How do I update FeatureTable?

Please see my another post:

https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/not-working-featuretable-using-cl...

 

Thanks.

Forrest

0 Kudos
ForrestLin
Frequent Contributor

@ReneRubalcava 

It works after calling featureTable refresh method in 

featureLayer.applyEdits(edits)
      .then( editsResult => {
           featureTable.refresh();
       });
 
Thanks.
 
Forrest
0 Kudos
ForrestLin
Frequent Contributor

By the way, how to clear/remove all features in FeatureLayer?

Is it the right approach?

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