Hi All,
I have couple of layers one is "master" layer another one is "temporary" layer. Both layer have same fields.
User will create new feature in "temporary" layer , once approved the specific feature need to move to "master" layer.
I need know the how to copy the feature from temporary layer to master layer.
Please help me if someone have idea.
Thanks in advance.
I did something like in this blog post.
Here is a codepen.
It's something like this.
function copyLayer(lyr, title) {
const tempLayer = new FeatureLayer({
title,
fields: lyr.fields.map(x => x.clone()),
geometryType: lyr.geometryType,
renderer: lyr.renderer.clone(),
spatialReference: lyr.spatialReference.clone(),
source: [],
visible: false
});
return tempLayer;
}
// later, might need a where: 1=1 query
const { features } = await soureLayer.queryFeatures();
const result = await localLayer.applyEdits({
addFeatures: features
})
.catch(err => console.log(error));
localLayer.refresh();
Hi,
Thanks for the reply. Sample code seems to be copy entire feature from temp layer to master layer. I need to copy only few features not entire feature. Kindly let me know how to do it?
Change the query used for queryFeatures to only fetch the features you are interested in.
https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html