Select to view content in your preferred language

My graphics layer gets removed after feature.applyedits

916
2
Jump to solution
12-09-2016 03:37 PM
by Anonymous User
Not applicable

Hi all,

Once I apply edits on click event, my graphic layer disappears. Any reason why?


\\my graphic layer
var GraphicsBuffer = new GraphicsLayer();
                GraphicsBuffer.id = 'GraphicsBuffer';


$("#createproject").click(function () {
                    $("#partone").hide();
                    $("#parttwo").show();
                    projectarea.setAttributes({ "START_DATE": Date.parse($("#projectstartdate").val()), "FINISH_DATE": "10/09/2016", "Name": $("#projectname").val(), "PROJECT_ID": $("#tesr").val(), "TREE_COUNT": $("#messages").text(), "ACRES": $("#area").text() });
                    console.log(projectarea);
                    featurelayerProject.applyEdits([projectarea], null, null, function () { console.log("Features updated!");}, function (error) { console.log("Features not updated! ", error); });‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I am not getting any errors.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Alex,

   Is projectarea as graphic object that was added to your GraphicsLayer? Graphics can only exist in one layer so if you add the graphic to your FeatureLayer then it will be removed from your GL. To avoid this you need to clone the graphic before you add it to your FeatureLayer.

var gra = new Graphic(projectarea.toJson());‍
featurelayerProject.applyEdits([gra], null, null, 
  function () {
    console.log("Features updated!");
  },
  function (error) {
    console.log("Features not updated!", error);
  }
);

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Emeritus

Alex,

   Is projectarea as graphic object that was added to your GraphicsLayer? Graphics can only exist in one layer so if you add the graphic to your FeatureLayer then it will be removed from your GL. To avoid this you need to clone the graphic before you add it to your FeatureLayer.

var gra = new Graphic(projectarea.toJson());‍
featurelayerProject.applyEdits([gra], null, null, 
  function () {
    console.log("Features updated!");
  },
  function (error) {
    console.log("Features not updated!", error);
  }
);
by Anonymous User
Not applicable

Perfect Thanks!

0 Kudos