Select to view content in your preferred language

FeatureLayer On Edits

482
2
Jump to solution
08-29-2023 12:16 PM
RobertBossio
New Contributor II

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
});

0 Kudos
1 Solution

Accepted Solutions
JoelBennett
MVP Regular Contributor

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));

 

View solution in original post

2 Replies
JoelBennett
MVP Regular Contributor

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));

 

RobertBossio
New Contributor II

Thanks, @joe! I learned something new about JS. That worked perfectly. I appreciate you responding.

0 Kudos