Sorry for my bad English. When I tried to change the symbol of many geometry by using Query and applyEdit(), when i clicked the button to do so, the geometry met the query conditions only blink and get back to the old symbol. Here is my code:
var pointGeometry = new Point({
x: 115.31,
y: -2.14,
spatialReference: 4326
});
var bufferDistance = 75;
var bufferGeometry = geometryEngine.geodesicBuffer(pointGeometry, bufferDistance, "kilometers");
var query = fl.createQuery();
query.geometry = bufferGeometry;
query.returnGeometry = true;
fl.queryFeatures(query).then(function (response) {
var geometryResult = [];
response.features.forEach(function (feature) {
if (feature.attributes.IsComplete == "true") {
geometryResult.push(feature.attributes[fl.objectIdField]);
}
});
console.log(geometryResult);
var query2 = fl.createQuery();
query2.objectIds = geometryResult;
fl.queryFeatures(query2).then(function (result) {
let sym = {
type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
color: "red",
outline: { // autocasts as new SimpleLineSymbol()
color: [128, 128, 128, 0.5],
width: "0.5px"
}
};
result.features.forEach(function (feature) {
feature.symbol = sym;
});
const edits = {
updateFeatures: result.features
};
fl.applyEdits(edits).then(function () {
console.log("success");
}).catch(function (error) {
console.error("fail: ", error);
});
});
});
Thank for your help
You cannot change the symbols of features in a FeatureLayer. The symbol changes happen through the layer's renderer. Be sure to check out the Styles and data visualization doc to learn more info.