WAB Dev 2.19 / JavaScript 3.x
I have a custom widget with a button click that attaches to the reply_click() function below. It successfully applies a query to select the feature (via attribute query), sets up a graphic to act as a highlight around the selected point feature and I can confirm the "selGraphic" that is created has the correct geometry and attributes.
What I am trying to implement is a way for the user to edit ("move" only) that selected graphic and then update the underlying layer.layerObject.selectFeatures with the graphic that was "moved" by the user.
I'm not getting any errors and the layer.layerObject.applyEdits() doesn't seem to choke or have any issues, however no edits are actually applied. I've tried several variations of the applyEdits() method with similar results, all of these do nothing:
layer.layerObject.applyEdits(selGraphic, null, features[0])
layer.layerObject.applyEdits([selGraphic], null, features[0])
layer.layerObject.applyEdits([selGraphic], [], features[0])
layer.layerObject.applyEdits([selGraphic], null, [features[0]])
Any guidance is appreciated!
reply_click: function (e) {
//console.log(e.target.id)
this.map.itemInfo.itemData.operationalLayers.forEach(layer => {
if (layer.layerObject) {
if (layer.title === "Water Use Application Facilities") {
var queryTask = new QueryTask(layer.layerObject)
var query = new Query();
query.returnGeometry = true;
query.outFields = ['*']
query.where = "facilityId = '" + e.target.id + "'"
layer.layerObject.selectFeatures(query).then(function (features) {
if (layer.layerObject.geometryType === 'esriGeometryPoint' && features.length === 1) {
this.map.centerAt(features[0].geometry);
this.map.graphics.clear();
var selSymbolJson = {
"color": [
0,
0,
0,
0
],
"size": 30.5,
"angle": 0,
"xoffset": 0,
"yoffset": 0,
"type": "esriSMS",
"style": "esriSMSCircle",
"outline": {
"color": [
0,
255,
250,
255
],
"width": 2.50,
"type": "esriSLS",
"style": "esriSLSSolid"
}
}
var attributes = {};
attributes['appId'] = features[0]['attributes'].appId //this.appId
attributes['facilityId'] = features[0]['attributes'].facilityId
attributes['facilityType'] = features[0]['attributes'].facilityType
attributes['facilityName'] = features[0]['attributes'].facilityName
attributes['permitId'] = features[0]['attributes'].permitId
var selGraphic = new Graphic(features[0].geometry, symbolJsonUtils.fromJson(selSymbolJson), attributes)
console.log(features[0].geometry)
map.graphics.clear();
map.graphics.add(selGraphic);
this.editToolbar = new Edit(this.map, { allowAddVertices: false });
this.editToolbar.activate(Edit.MOVE, selGraphic);
this.map.on("click", function (evt) {
layer.layerObject.applyEdits(selGraphic, null, features[0])
map.graphics.clear();
map.graphics.add(selGraphic);
})
}
});
}
}
})
}