Select to view content in your preferred language

Updating FeatureLayer with features being added or removed

232
0
08-12-2022 09:30 PM
Aeseir
by
Frequent Contributor

I am trying to figure out the most efficient way to manipulate features on the FeatureLayer. Specifically:

  • If feature not on layer - add it
  • If feature on layer already - ignore it
  • If feature on layer but not in feature list - remove it 

 

function GetFeatures(data: Features[]) {
var polygonFeatures = data.filter(e => e.isPolygon);
var pointFeatures = data.filter(e => e.isPoint);

this.polygonFeatureLayer?.queryFeatures({ where: "id NOT IN (" + polygonFeatures .map(x => { return "'" + x.id + "'" }) + ")" })
      .then((results) => this.polygonFeatureLayer?.applyEdits({ deleteFeatures: results.features }));

this.polygonFeatureLayer?.applyEdits({addFeatures: convertFeaturesToFormat(polygonFeatures)});
}

 

I am about to put together a function for omitting features so it doesn't duplicate them.

 

What is the most efficient way to do the above?

0 Kudos
0 Replies