I'm setting up an event listener for Edits events on a FeatureLayer. When the even is trigged, we have access to the edits that were completed, but we don't get a reference to the layer the edits were applied to. If you have multiple layers on the map, is there a way to determine what layer the edits were applied to?
Or, is there a better way to identify when edits are complete on a layer?
Thanks.
Example:
layer.on('edits', (result) => {
console.error(result); //result has edits, but can't reference the layer the edits were applied to
});
Solved! Go to Solution.
You can use bind to pass a reference to the layer into your handler:
layer.on("edits", function(editLayer, result) {
alert(editLayer.id + " :: " + editLayer.title + " :: " + editLayer.type);
}.bind(this, layer));
You can use bind to pass a reference to the layer into your handler:
layer.on("edits", function(editLayer, result) {
alert(editLayer.id + " :: " + editLayer.title + " :: " + editLayer.type);
}.bind(this, layer));
Thanks, @joe! I learned something new about JS. That worked perfectly. I appreciate you responding.