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.
Solved! Go to Solution.
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);
}
);
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);
}
);
Perfect Thanks!