This article describes how to make a feature layer editable or not editable. For a feature layer to be editable, it has to meet these requirements:

Step 1 - Create an editable layer

By default, the FeatureLayer builder creates non-editable feature layers. You can specify the editable flag, the edit configuration, or both. If you set only the flag to true, a default IFeatureEditConfiguration is created and used. This configuration marks all features as editable.

If you set only the configuration, the editable flag is set to true automatically.

If you want a layer that is initially not editable, but that you can toggle to an editable layer later, you must set a valid IFeatureEditConfiguration, and set the editable flag to false in the builder.

Program: Create a layer
// non editable layer by default
auto nonEditableLayer = FeatureLayer::newBuilder().model(model).build();
// editable layer using a default edit configuration.
auto defaultConfigLayer = FeatureLayer::newBuilder().model(model).editable(true).build();
// editable layer using a non-default edit configuration.
auto myEditConfiguration = std::make_shared<SimpleEditConfiguration>();
auto customConfigLayer = FeatureLayer::newBuilder().model(model).editConfiguration(myEditConfiguration).build();
// editable layer but initially read-only
auto readOnlyLayer = FeatureLayer::newBuilder().model(model).editConfiguration(myEditConfiguration).editable(false).build();

Step 2 - Toggle the editing

To allow features to be edited on a layer with a IFeatureEditConfiguration, change the editable flag.

Program: Toggle editing
readOnlyLayer->setEditable(true);