Select to view content in your preferred language

Cannot change symbol of geometry when using applyEdits()

276
1
02-15-2023 06:54 PM
LazyDogz
Emerging Contributor

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

 

 

0 Kudos
1 Reply
UndralBatsukh
Esri Regular Contributor

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.

0 Kudos