I am attempting to display a visualization of data in a FeatureLayer. I am pulling in data from a Feature Service and, based on user input, I am attempting to edit the colors of the features. When this feature stopped working, I tried to narrow it down as much as I could. What I am left with is the following:
I have a Feature Layer that has a SimpleRenderer. That renderer has a VisualVariable that includes the following ColorVariable:
var rendColorInfo = {
type: "color",
valueExpression: "$feature.COLOR_FIELD",
minDataValue: -3.0,
maxDataValue: 3.0,
stops: getStops(-3.0, 3.0)
};
renderer.visualVariables = [rendColorInfo];
This correctly displays a color for the default value of the feature. After instantiating the MapView, Map, and FeatureLayer, I call the following code:
lyr.queryFeatures().then((featureSet) => {
let q = featureSet.features;
console.log(q[0]);
q[0].attributes.COLOR_FIELD = -3;
console.log(q[0]);
lyr.applyEdits({ updateFeatures : [q[0]] }).then((result) => { console.log(result); });
});
Where lyr is the FeatureLayer.
As a proof of concept, I am only trying to update the value of the color field on one of the ~250 features in the map. Logging out q[0] before I set the COLOR_FIELD attribute, the value in the log is 2, which is correct. Logging after setting the attribute shows the value at -3. The OBJECTID field is set and consistent before and after setting the attribute. After passing these values to the applyEdits method, no change is observed in any of the features, and the logged result is
{addFeatureResults: Array(0), updateFeatureResults: Array(0), deleteFeatureResults: Array(0)}
I cannot figure out what the problem is, as the edits are not being applied even after following all of the documentation to get to this point. The source for the featureLayer is set via the URL attribute. If anyone has encountered this issue and solved it, please let me know.