HOW TO

Limit the number of edits on a web map configured using ArcGIS API for JavaScript

Last Published: April 25, 2020

Summary

The ability to disable editing a web map is possible using JavaScript by implementing the drawToolbar.deactivate() and editToolbar.deactivate() functions in a script.

To set a certain number of allowable edits in a web map configured using ArcGIS API for JavaScript before editing is disabled, the script requires a counter with a preset number that triggers the deactivate function when the counter reaches the specified number.

Procedure

The following instructions demonstrate how to limit the number of edits performed using ArcGIS API for JavaScript. The script sample below sets the count to less than or equals to 3: 
  1. Set up a counter parameter for added graphic.
...
//Set up the counter for graphic added
count = count + 1; 
console.log("Graphic Count", count);
...
  1. Set an if...else statement to a activate the drawToobar.deactivate() and editToolbar.deactivate() function with specified number of edits.
...
//Editing is enabled for 3 or less edit points
if(count <= 3) {
appliedEdits = selectedTemplate.featureLayer.applyEdits([newGraphic], null, null);
}
else
{
drawToolbar.deactivate();
editToolbar.deactivate();
alert(" You have successfully completed 3 edits!"); 
}
return count; 
 });
...
Note:
Edit the code segment, "if(count <= 3)" with the desired number of edits allowed.

Article ID: 000014900

Software:
  • ArcGIS API for JavaScript 4 x
  • ArcGIS API for JavaScript 3 x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options