When using FeatureLayers and adding new features using applyEdits, "empty" features are being created. The graphics are added, but there isn't any feature data.

561
5
07-16-2020 10:57 AM
JonathanBorgia
New Contributor

When using FeatureLayers and adding new client side features using applyEdits, "empty" features are being created. The graphics are added, but there isn't any feature data. I am using a unique ID for each feature ("scan number") and the empty features ids' are not among those in the data I am passing. It is like they are being generated. How do I remove or prevent this?

0 Kudos
5 Replies
KenBuja
MVP Esteemed Contributor

Can you post any code to show how you're using applyEdits?

0 Kudos
JonathanBorgia
New Contributor

I've tried a few different things. queryFeatures and applyEdits({removeFeatures: results.features}) and then in the 'then' adding the new features (hopefully removing all the old features and adding the new), but that doesn't work. If I use updateFeatures then the duplicate/blank features are gone. I was hoping that the objectId would mean that the features would be unique values and that any updates would update that objectId (like a hashmap), but that doesn't seem to be the case. Or, if it is, then something even stranger is going on.

```

replaceFeatureLayerFeatures(title: string, features: Collection<Graphic>, renderer: Renderer) {
const selectedFeatureLayer = (this.map.layers.find(layer => layer.id === this.layerService.featuresGroupLayer.id) as GroupLayer).findLayerById(title) as FeatureLayer;

if (selectedFeatureLayer) {
let query = new Query();
selectedFeatureLayer.queryFeatures(query).then(results => {
console.log('results', results);
selectedFeatureLayer.applyEdits({ addFeatures: features });
});
} else {
console.log(`creating a ${title} layer`);
this.createFeatureLayer(title, features, renderer);
}
}
0 Kudos
KenBuja
MVP Esteemed Contributor

In your code, what are you expecting from your query? You haven't set any query parameters. If you want to get all the features, then you can just use

selectedFeatureLayer.queryFeatures().then(results => {
0 Kudos
JonathanBorgia
New Contributor

Unfortunately, the extra features still show up even then

0 Kudos
JonathanBorgia
New Contributor

So, there is an issue when assigning Renderer.popupTemplate as a function in Javascript. It only sometimes gets the feature data and builds correctly. Not sure where to report this bug. Assigning it a static object works fine.

0 Kudos