Select to view content in your preferred language

copy feature

06-22-2021 09:19 AM
New Contributor

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.

Tags (1)
0 Kudos
3 Replies
Frequent Contributor II

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({
        fields: => 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));
0 Kudos
New Contributor


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?

0 Kudos
Frequent Contributor II

Change the query used for queryFeatures to only fetch the features you are interested in.