无法应用 Edits ArcGIS FeatureLayer

Unable to applyEdits ArcGIS FeatureLayer

晚上好,

我正在尝试使用 applyEdits 属性更新我的 featureLayer。我面临一些问题,因为我无法更改特定层的值。我不确定这里有什么问题请帮助我,干杯! (此项目在 ArcGIS API 3.25 上 运行)

 let testButton = document.getElementById('testButton')
    if (testButton){
    testButton.addEventListener("click",function(){
      var announcementInput = document.getElementById('announcementInput').value;
      console.log(announcementInput)
 
      featureLayer.applyEdits(
                  null,
                  [{
                    "attributes":{
                      "objectid":objectid,
                      "announcement": announcementInput, // I want to update this value
                  }
                  }],
                  null,
                  null,
                  null
    })
    }
    else{
      console.log("Not working")
    }
      });
    });

我认为问题在于您需要传递 Graphic 个元素,您只是在传递一个对象。应该是这样的,

// first get the feature you want to edit
const query = new Query();
query.objectIds = [objectid];
query.outFields = [ "*" ];
featureLayer.queryFeatures(query, function(featureSet) {
    if (featureSet.features.length === 0) {
        return;
    }
    // now update the desire attribute
    const feature = featureSet.features[0];
    feature.attributes.announcement = announcementInput;
    featureLayer.applyEdits(
      null,
      [feature],
      null,
      null,
      null
    })
});