Hi all,
I have made a buffer (project area) from roads that I would like to add to feature layer. I need to programmatically enter a start date, finish date and Name of project. I am trying the code below with an empty feature layer (made only to collect the buffers created) that already has the three attributes described up. Any idea?
featurelayerProject.applyEdits([geometry], null, null);
Solved! Go to Solution.
In my app, a user selects a number of features (resulting in array featureSet) and through a dialog box, changes some of the attributes. The code updates the attributes of those features and the changes are applied to the feature layer without the use of the Attribute Inspector.
array.forEach(featureSet, function (feature) {
feature.attributes.Priority = registry.byId('cboPriority').get("value");
feature.attributes.Management = registry.byId('cboManagement').get("value");
feature.attributes.Criteria1 = registry.byId('cboCriteria1').get("value");
});
layerFeatureLayer.applyEdits(null, featureSet, null, function () { console.log("Features updated!"); }, function (error) { console.log("Features not updated! ", error); });
You can set the attributes of a graphic using the setAttributes method
gra.setAttributes( {"XCoord":evt.mapPoint.x,"YCoord":evt.mapPoint.y,"Plant":"Mesa Mint"});
Another way to do this is
gra.attributes.XCoord = evt.mapPoint.x;
That is not a bad idea except that it will be harder for me share it around. I thought of the feature layer because I can easily have it hosted in AGOL or ArcGIS Server. Also I want to achieve this programmatically because I don't want the users to deal with the attribute inspector. Maybe I can add a graphic to a feature layer?
Alex,
I am not sure I am following. But the featurelayerProject.applyEdits expects a graphic not a geometry.
featurelayerProject.applyEdits([geometry], null, null);
Ha you are right Robert. I will try a graphic.
In my app, a user selects a number of features (resulting in array featureSet) and through a dialog box, changes some of the attributes. The code updates the attributes of those features and the changes are applied to the feature layer without the use of the Attribute Inspector.
array.forEach(featureSet, function (feature) {
feature.attributes.Priority = registry.byId('cboPriority').get("value");
feature.attributes.Management = registry.byId('cboManagement').get("value");
feature.attributes.Criteria1 = registry.byId('cboCriteria1').get("value");
});
layerFeatureLayer.applyEdits(null, featureSet, null, function () { console.log("Features updated!"); }, function (error) { console.log("Features not updated! ", error); });
Just tried something similar and it works! Sweet. Thank you guys