Adding ArcGIS's editing capabilities
Currently, the food and drinks layer is being fetched as a read-only map service located at the URL: http://arcgismachine:6080/arcgis/rest/services/Bestaurants/MapServer/0
. The only difference is that it points to the enterprise geodatabase. You can see the following code in mybestaurants.html
which confirms that:
//load the food and drinks layer into an object lyr_foodanddrinks = new esri.layers.FeatureLayer("http://arcgismachine:6080/arcgis/rest/services/Bestaurants/MapServer/0", { outFields: ["*"] } );
We won't be able to edit MapServerlayer
, we have to use FeatureServer
. We will show how to change this in the next section.
Adding or updating records in a service with ArcGIS JavaScript API is simple. We only need to use the applyEdits
method on the FeatureLayer
object. This method accepts a record and some parameters for the response; what we are interested in is to insert a record. The following code shows how to prepare a record with three fields for...