Solved! Go to Solution.
var attributes = { OBJECTID: 12, name: "My name" }; var feature = new Graphic(null, null, attributes); var updateFeatures = []; updateFeatures.push(feature); layer.applyEdits(null, updateFeatures, null, function(addResults, updateResults, deleteResults){ console.log('success', updateResults); }, function(error){ console.log('error', error); });
var attributes = { OBJECTID: 12, name: "My name" }; var feature = new Graphic(null, null, attributes); var updateFeatures = []; updateFeatures.push(feature); layer.applyEdits(null, updateFeatures, null, function(addResults, updateResults, deleteResults){ console.log('success', updateResults); }, function(error){ console.log('error', error); });
I'm still confused how to specify the objectID
do I need to set the feature layer as editable before I can do any modifications?
Yes. You need to enable editing on your feature layer.
Thanks for your help, but how to set it editable? sorry I know it is a idiot question, but I'm really confused.
I set it editable as the picture but when I test it using featureLayer.isEditable(), why it still returns false?
featurelayer.on("load", function(){ console.log(featurelayer.isEditable()); });
Hello,
Example 1 :
var map = new Map("map", {
basemap: "dark-gray",
zoom: 3,
});
layer = new FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/FeatureServer/0");
attributes = { objectid: 119369, typdamage: "Update successfully" };
feature = new Graphic( null, null, attributes );
map.addLayer(layer);
map.onLayerAddResult = () => {
layer.applyEdits(null, [feature], null,
function (add, update, del) {
console.log('success', update);
});
};
Exemple 2 :
var map = new Map("map", {
basemap: "dark-gray",
zoom: 3,
});
layer = new FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/FeatureServer/0");
attributes = { objectid: 119369, typdamage: "Update successfully" };
feature = new Graphic( null, null, attributes );
map.addLayer(layer);
setTimeout(() => {
layer.applyEdits(null, [feature], null,
function (add, update, del) {
console.log('success', update);
},
function (error) {
console.log('error applyEdits \n', error);
});
}, 2000);
Bertrand