require(["esri/dijit/editing/Editor"], function(Editor) { /* code goes here */ });
Description
(Added at v2.0)
The Editor widget provides out-of-the-box editing capabilities using an editable layer in a Feature Service. It combines the out-of-the-box
TemplatePicker
,
AttachmentEditor
,
AttributeInspector
and
GeometryService
to provide feature and attribute editing. When building editing applications, try to take advantage of the customizable out-of-the-box Editor widget when possible.
Editing behaviors:
- To create features, click a feature template in the template picker then start drawing the feature.
- To move features, click and drag the feature to a new location.
- To delete features, click the feature then press the 'Delete' button on the attribute inspector.
- To edit features, click the feature to display the vertices and the attribute inspector.
- Editing Vertices:
- Add new vertices by clicking a ghost vertex.
- Right-click to delete a vertex.
- Click and drag to move a vertex to a new location.
- Attribute edits are saved automatically when you change selection, change the focus field, or press enter.
- Geometry edits are saved automatically.
Samples
Search for
samples that use this class.
Constructors
Constants
CREATE_TOOL_ARROW | Arrow tool |
CREATE_TOOL_AUTOCOMPLETE | Autocomplete polygon tool |
CREATE_TOOL_CIRCLE | Circle tool |
CREATE_TOOL_ELLIPSE | Ellipse tool |
CREATE_TOOL_FREEHAND_POLYGON | Freehand polygon tool |
CREATE_TOOL_FREEHAND_POLYLINE | Freehand polyline tool |
CREATE_TOOL_POLYGON | Polygon tool |
CREATE_TOOL_POLYLINE | Polyline tool |
CREATE_TOOL_RECTANGLE | Rectangle tool |
CREATE_TOOL_TRIANGLE | Triangle tool |
CSS
esri/dijit/editing/Editor | Download source
Properties
Methods
startup() | None | Finalizes the creation of the widget. |
Events
[ On Style Events | Connect Style Event ]
All On Style event listeners receive a single event object. Additionally, the event object also contains a 'target' property whose value is the object which fired the event.
Events
load | | Fires when the widget has fully loaded. |
Old Events
onLoad() | Fires when the widget has fully loaded. |
Constructor Details
Creates a new Editor object.
Parameters:
<Object > params |
Required |
Parameters that define the functionality of the editor widget. Create a new settings object to pass to the widget (see options). |
<Node | String > srcNodeRef |
Required |
HTML element where the widget should be rendered. |
params
properties:
<Object > settings |
Optional |
Create a new settings object that defines the capabilities of the widget. See the object specifications table below for details. |
Object Specifications: <createOptions
>
<String[] > polygonDrawTools |
Optional |
See the constants list for valid options. |
<String[] > polylineDrawTools |
Optional |
See the constants list for valid options. |
<fieldInfo
>
<dijit > customField |
Optional |
Specify a custom dijit as the editor for this field. |
<String > fieldName |
Required |
The name of the field to customize. |
<Object > format |
Optional |
Specify this for editing time in a Date field. Specify it as an object with a single boolean property, 'time'. Note: In order to use this, the field must be formatted as either shortDateShortTime , shortDateLEShortTime , shortDateShortTime2 , shortDateLEShortTime24 , shortDateLongTime , shortDateLELongTime , shortDateLongTime24 , or shortDateLELongTime24 .
'fieldInfos':[
{'fieldName':'name','label':'Name'},
{'fieldName':'email','label':'Email'},
{'fieldName':'notedate','label':'Date','format':{'time':true}}
]
|
<Boolean > isEditable |
Optional |
Disable editing of the field. Setting this to true does not override a false value from the server. It will not allow editing directly within a PopupTemplate . |
<String > label |
Optional |
Define a label for the field. Setting this overrides the alias and field name from the service. |
<String > richTextPlugins |
Optional |
Use this option to override the default setting for the plug-in when using the rich text editor. See dijit/Editor for details. |
<String > stringFieldOption |
Optional |
Set the type of field to use when editing string values. See the constants table for a list of valid values. |
<String > tooltip |
Optional |
Define a tooltip for the field. |
<layerInfo
>
<Boolean > disableAttributeUpdate |
Optional |
If true, attributeInspector won't pop up when features in this featureLayer are selected. When adding a new feature, attributeInspector won't pop up either. |
<Boolean > disableGeometryUpdate |
Optional |
When true, the geometry is not editable. The default value is false. Requires ArcGIS Server feature service version 10.1 or greater (As of 2.6). |
<FeatureLayer > featureLayer |
Required |
Reference to the feature layer. |
<Object[] > fieldInfos |
Optional |
Customize how fields appear in the attribute inspector. If nothing is specified all fields, except the ObjectId and GlobalId are displayed. Specify FieldInfos to explicitly define the fields that are displayed and the field order. Added at version 2.2. See the fieldInfo object specifications table for details of each object. |
<Boolean > showGlobalID |
Optional |
Default is false. When true display the GlobalID field in the attribute inspector. |
<Boolean > showObjectID |
Optional |
Default is false. When true display the ObjectID field in the attribute inspector. |
<String > userId |
Optional |
Provide a userId for the currently logged-in user. If the application is using the IdentityManager it is not necessary to specify a userId since the feature layer has access to the credential object which contains this information. Requires ArcGIS Server feature service version 10.1 or greater (As of 2.6). |
<settings
>
<Object > createOptions |
Required |
Specify the polygon and polyline draw tools to include on the toolbar. Only applicable when toolbarVisible is true. See the createOptions object specifications table for details. |
<Boolean > enableUndoRedo |
Optional |
When true, enable undo/redo behavior. |
<String > geometryService |
Required |
Reference to the geometry service. Alternatively, you can set the geometry service using esri.config.defaults.geometryService (Required). |
<String[] > htmlFields |
Optional |
Specify which fields to display as a rich text editor. |
<Object[] > layerInfos |
Required |
Array of feature layer information objects. See the layerInfo object specifications table for details of each object. |
<Map > map |
Required |
Reference to the map (Required). |
<Number > maxUndoRedoOperations |
Optional |
When undo/redo is enabled, specify the maximum number of undo/redo operations to maintain. Default value is 10. |
<TemplatePicker > templatePicker |
Optional |
Reference to the TemplatePicker. Use this option if you want to modify the appearance of the template picker, for example set the number of rows and columns. |
<Object > toolbarOptions |
Optional |
Specify the tools to include on the toolbar. Only applicable when toolbarVisible is true. See the toolbarOptions object specifications table for details. |
<Boolean > toolbarVisible |
Optional |
If true display the editing toolbar. |
<UndoManager > undoManager |
Optional |
Specify an instance of the UndoManager for the Editor. |
<toolbarOptions
>
<Boolean > cutVisible |
Optional |
If true show the cut tool. |
<Boolean > mergeVisible |
Optional |
If true show the merge tool. Note that only polygons can be merged. |
<Boolean > reshapeVisible |
Optional |
If true show the reshape tool. |
Sample: Create a settings object that defines the capabilities of the widget.
var settings = {
map: map,
geometryService: new esri.tasks.GeometryService("http://servery/arcgis/rest/services/Geometry/GeometryServer"),
createOptions: { polygonDrawTools:[esri.dijit.editing.Editor.CREATE_TOOL_FREEHAND_POLYGON] },
layerInfos:layerInfos
};
Pass the settings to the widget
var params = {settings: settings};
var myFeatureServiceWidget = new esri.dijit.editing.Editor(params,'divFeatureServiceDijit');
myFeatureServiceWidget.startup();
Property Details
The default
Edit toolbar instance.
(Added at v3.14) Sample:
require([
"esri/dijit/editing/Editor",
"esri/map",
"...",
"dojo/domReady!"
], function (Editor, Map, ...){
var params = {
settings: {
map: map,
layerInfos: featureLayerInfos
}
};
var editorWidget = new Editor(params, 'editorDiv');
editorWidget.startup();
editorWidget.editToolbar.on('graphic-first-move', function( e ) {
console.log('Move has begun');
});
});
Method Details
Finalizes the creation of the widget. (Added at v3.12)
Event Details
[ On Style Events | Connect Style Event ]
Fires when the widget has fully loaded.
Fires when the widget has fully loaded.