Hide Table of Contents
esri/dijit/util
esri/layer/pixelFilters
esri/process
esri/support
esri/workers
Class: Edit

dojo.require("esri.toolbars.edit");

Description

(Added at v2.0)
The Edit toolbar is a helper class that provides functionality to move graphics or modify individual vertices, i.e., edit the geometry of existing graphics. To add new graphics, use the Draw toolbar. Updated at version 2.1 to include support for rotating and scaling.

Mouse behavior when editing features:
  • To move a feature, once the Edit toolbar is activated with that feature, press down on the feature, drag it, then let go at the new location.
  • To add a vertex to a polyline or polygon, click on a "ghost" vertices and move it to the new location.
  • To delete a vertex from a polyline or polygon, right-click the vertex and select 'Delete Vertex' from the menu. Only valid for polylines with at least three vertices and polygons with at least four vertices.
  • To rotate or scale a geometry click the handle and move to the desired location.

Samples

Search for samples that use this class.

Constructors

NameSummary
new esri.toolbars.Edit(map, options?)Creates a new Edit object.

Constants

NameDescription
EDIT_TEXTWhen a textSymbol point is in edit mode, double-clicking leads to text editing mode, which is a text box where uses can change the text content. Pressing Enter key or clicking outside applies the change to the text symbol.
EDIT_VERTICES

Display and edit vertices of a Polyline, Polygon, or Multipoint. For Polyline and Polygon ghost vertices are also displayed. Ghost vertices are points in between the existing points on a path or ring that is not yet part of the graphic. The last three points in a polygon, last two points in a line, and last point in a multipoint cannot be deleted.

The three edit operations are:
  • Add : Click and drag a ghost vertice to add it to the graphic.
  • Delete : Right-click a vertex and select "Delete".
  • Move: Click and drag a vertex.
MOVEMove graphic to a new location on the map. Applicable to Point, Polyline, or Polygon.
ROTATERotate the graphic. As of version 2.1.
SCALEScale or resize a graphic. As of version 2.1

Methods

NameReturn typeSummary
activate(tool, graphic, options?)NoneActivates the toolbar to edit the supplied graphic.
deactivate()NoneDeactivates the toolbar.
getCurrentState()ObjectAn object with the following properties that describe the current state.
Value Description
<Number> tool Indicates the current tool. Valid values are listed in the constants table.
<Graphic> graphic The graphic that is currently being edited.
<Boolean> isModified Indicates if the graphic has been modified.
.
refresh()NoneRefreshes the internal state of the toolbar.

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

NameEvent ObjectSummary
activate
{
  graphic: <Graphic>,
  tool: <String>
}
Activates the toolbar for editing geometries.
deactivate
{
  graphic: <Graphic>,
  info: <Object>,
  tool: <String>
}
Deactivates the toolbar and reactivates map navigation.
graphic-click
{
  graphic: <Graphic>,
  info: <Object>
}
Fires when a graphic is clicked.
graphic-first-move
{
  graphic: <Graphic>
}
Fires when the user begins to move a graphic.
graphic-move
{
  graphic: <Graphic>,
  transform: <Object>
}
Fired continuously as the graphic moves.
graphic-move-start
{
  graphic: <Graphic>
}
Fired when the mouse button is pressed down on the graphic, usually while moving a graphic.
graphic-move-stop
{
  graphic: <Graphic>,
  transform: <Object>
}
Fired when the mouse button is released, usually after moving the graphic.
rotate
{
  graphic: <Graphic>,
  info: <Object>
}
Fires continuously as a graphic is rotated.
rotate-first-move
{
  graphic: <Graphic>
}
Fires when the user begins to drag a handle to rotate the graphic.
rotate-start
{
  graphic: <Graphic>
}
Fires when a user clicks on the handle to begin rotating a graphic.
rotate-stop
{
  graphic: <Graphic>,
  info: <Object>
}
Fires when the mouse button is released from the rotate handle to finish rotating the graphic.
scale
{
  graphic: <Graphic>,
  info: <Object>
}
Fires continuously as the graphic is being scaled.
scale-first-move
{
  graphic: <Graphic>
}
Fires when the user begins to drag a handle to scale the graphic.
scale-start
{
  graphic: <Graphic>
}
Fires when a user clicks on the handle to scale or resize a graphic.
scale-stop
{
  graphic: <Graphic>,
  info: <Object>
}
Fires when the mouse button is released from the scale handle to finish scaling the graphic.
vertex-add
{
  graphic: <Graphic>,
  vertexinfo: <Object>
}
Fired after a new vertex is added to a polyline or polygon or a new point is added to a multipoint.
vertex-click
{
  graphic: <Graphic>,
  vertexinfo: <Object>
}
Fired when the mouse button is clicked on the vertex of a polyline or polygon or a point in a multipoint.
vertex-delete
{
  graphic: <Graphic>,
  vertexinfo: <Object>
}
Fired after a vertex(polyline, polygon) or point(multipoint) is deleted.
vertex-first-move
{
  graphic: <Graphic>,
  vertexinfo: <Object>
}
Fired when the user begins to move the vertex of a polyline or polygon or a point of a multipoint.
vertex-mouse-out
{
  graphic: <Graphic>,
  vertexinfo: <Object>
}
Fires as the mouse exits a vertex(polyline, polygon) or a point(multipoint).
vertex-mouse-over
{
  graphic: <Graphic>,
  vertexinfo: <Object>
}
Fired when the mouse moves over a vertex (polyline, polygon) or point (multipoint).
vertex-move
{
  graphic: <Graphic>,
  transform: <Object>,
  vertexinfo: <Object>
}
Fired continuously as the user is moving a vertex (polyline, polygon) or point (multipoint).
vertex-move-start
{
  graphic: <Graphic>,
  vertexinfo: <Object>
}
Fired when the mouse button is pressed down on a vertex (polyline, polygon) or point (multipoint).
vertex-move-stop
{
  graphic: <Graphic>,
  transform: <Object>,
  vertexinfo: <Object>
}
Fired when the mouse button is released from a vertex (polyline, polygon) or point(multipoint).
Constructor Details

new esri.toolbars.Edit(map, options?)

Creates a new Edit object. A map is a required parameter.
Parameters:
<Map> map Required Map the toolbar is associated with.
<Object> options Optional Optional parameters. See options list.
options properties:
<Boolean> allowAddVertices Optional Specifies whether users can add new vertices. Valid for polyline and polygon geometries.
<Boolean> allowDeleteVertices Optional Specifies whether users can delete vertices. Valid for polyline, polygon and multipoint geometries.
<LineSymbol> ghostLineSymbol Optional Line symbol used to draw the guild lines, displayed when moving vertices. Valid for polyline and polygon geometries.
<MarkerSymbol> ghostVertexSymbol Optional Marker symbol used to display the insertable vertices. Valid for polyline and polygon geometries.
<Node | String> textSymbolEditorHolder Optional If users want to place the text symbol editor to a user defined HTML element.
<Boolean> uniformScaling Optional When true, if the geometry is re-sized the aspect ration will be preserved. 
<MarkerSymbol> vertexSymbol Optional Marker symbol used to draw the vertices. Valid for polyline and polygon geometries.
Sample:
  editToolbar = new esri.toolbars.Edit(map);
Method Details

activate(tool, graphic, options?)

Activates the toolbar to edit the supplied graphic. After activation the toolbar is ready for user interaction using the specified tool.
Parameters:
<String> tool Required Specify the active tool(s). Combine tools using the | operator. See the Constants table for a list of valid values.
<Graphic> graphic Required The graphic to edit.
<Object> options Optional See the object specifications table below for the structure of the options object.
Object Specifications:
<options>
<Boolean> allowAddVertices Optional Specifies whether users can add new vertices. Valid geometry: Polyline, Polygon
<Boolean> allowDeleteVertices Optional Specifies whether users can delete vertices. Valid geometry: Polygon, Polygon, Multipoint
<MarkerSymbol> boxHandleSymbol Optional Symbol to use when rotating or scaling geometries.
<LineSymbol> boxLineSymbol Optional Symbol for guide lines, displayed when rotating or moving geometries.
<LineSymbol> ghostLineSymbol Optional Symbol for guide lines, displayed when moving vertices
<MarkerSymbol> ghostVertexSymbol Optional Symbol for insertable vertices
<Boolean> textSymbolEditorHolder Optional Specifies whether users should place the text symbol editor to a user defined HTML element
<Boolean> uniformScaling Optional Specifies whether the geometry is resized if the aspect ratio will be preserved.
<MarkerSymbol> vertexSymbol Optional Symbol for vertices
Sample:
//Use the edit toolbar to edit vertices 
editToolbar.activate(esri.toolbars.Edit.EDIT_VERTICES , evt.graphic);
//Combine tools 
editToolbar.activate(esri.toolbars.Edit.MOVE | esri.toolbars.Edit.SCALE, evt.graphic);

deactivate()

Deactivates the toolbar. Call this method to deactivate the toolbar after editing the graphic.
Sample:

editToolbar.deactivate();

getCurrentState()

An object with the following properties that describe the current state.
Value Description
<Number> tool Indicates the current tool. Valid values are listed in the constants table.
<Graphic> graphic The graphic that is currently being edited.
<Boolean> isModified Indicates if the graphic has been modified.
Return type: Object

refresh()

Refreshes the internal state of the toolbar.
Event Details
[ On Style Events | Connect Style Event ]

activate

Activates the toolbar for editing geometries. Activating the toolbar disables map navigation. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The graphic to edit whose vertices will be edited or moved.
<String> tool The editing type. The Constants table lists valid editing values.

deactivate

Deactivates the toolbar and reactivates map navigation. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The graphic the toolbar was associated with.
<Object> info

The info object has the following properties:


{

  isModified:<Boolean>

}

<String> tool The editing type. The Constants table lists valid editing values.
Sample:
require([
 ... 
], function( ... ) {
  editToolbar.on("deactivate", function(evt) {
    if(evt.info.isModified){
      firePerimeterFL.applyEdits(null, [evt.graphic], null);
    }
  });
  ...
});
See also: deactivate()

graphic-click

Fires when a graphic is clicked. Applicable only when the MOVE tool is active. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The clicked graphic.
<Object> info See the object specifications table below for the structure of the info object.
Object Specifications:
<info>
<Point> mapPoint Location of mouse click in map coordinates.
<Point> screenPoint Location of mouse click in screen coordinates (pixels).

graphic-first-move

Fires when the user begins to move a graphic. Applicable only when the MOVE tool is active. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The graphic associated with the toolbar.

graphic-move

Fired continuously as the graphic moves. Applicable only when the MOVE tool is active. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The graphic associated with the toolbar.
<Object> transform Represents the linear transformation applied to the graphic.

graphic-move-start

Fired when the mouse button is pressed down on the graphic, usually while moving a graphic. Applicable only when the MOVE tool is active. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The graphic associated with the toolbar.

graphic-move-stop

Fired when the mouse button is released, usually after moving the graphic. Applicable only when the MOVE tool is active. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The graphic associated with the toolbar.
<Object> transform Represents the linear transformation applied to the graphic.

rotate

Fires continuously as a graphic is rotated. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The rotated graphic.
<Object> info

The info object has the following properties:


{

  transform: <Object>,

  angle: <Number>

  around: <Object>

}

Sample:
require([
 ... 
], function( ... ) {
  editToolbar.on('rotate',function(evt){
    var info = evt.info;
    var around = info.around; //x,y,scalex,scaley
    var angle = info.angle;
    var transform = info.transform //dx,dy,xx,xy,yx,yy
  });
  ...
});

rotate-first-move

Fires when the user begins to drag a handle to rotate the graphic. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The rotated graphic.
Sample:
require([
 ... 
], function( ... ) {
  editToolbar.on('rotate-first-move',function(evt){
    console.log('Rotating');
  });
  ...
});

rotate-start

Fires when a user clicks on the handle to begin rotating a graphic. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The rotated graphic.
Sample:
require([
 ... 
], function( ... ) {
  editToolbar.on('rotate-start',function(evt){
    console.log('Start Rotating');
  });
  ...
});

rotate-stop

Fires when the mouse button is released from the rotate handle to finish rotating the graphic. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The rotated graphic.
<Object> info

The info object has the following properties:


{

  transform: <Object>,

  angle: <Number>

  around: <Object>

}

Sample:
require([
 ... 
], function( ... ) {
  editToolbar.on('rotate-stop',function(evt){
    var info = evt.info;
    var around = info.around; //x,y,scalex,scaley
    var angle = info.angle;
    var transform = info.transform //dx,dy,xx,xy,yx,yy
  });
  ...
});

scale

Fires continuously as the graphic is being scaled. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The scaled graphic.
<Object> info

The info object has the following properties:


{

  transform: <Object>,

  scaleX: <Number>,

  scaleY: <Number>,

  around: <Object>

}

Sample:
require([
 ... 
], function( ... ) {
  editToolbar.on('scale',function(evt){
    var info = evt.info;
    var around = info.around;  //height,width,x,y
    var transform = info.transform; //dx,dy,xx,xy,yx,yy
    var scalex = info.scaleX;
    var scaley = info.scaleY;
  });
  ...
});

scale-first-move

Fires when the user begins to drag a handle to scale the graphic. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The scaled graphic.
Sample:
require([
 ... 
], function( ... ) {
  editToolbar.on('scale-first-move',function(evt){
    console.log('Begin Scaling');
  });
  ...
});

scale-start

Fires when a user clicks on the handle to scale or resize a graphic. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The scaled graphic.
Sample:
require([
 ... 
], function( ... ) {
  editToolbar.on('scale-start',function(evt){
    console.log('Scaling Started');
  });
  ...
});

scale-stop

Fires when the mouse button is released from the scale handle to finish scaling the graphic. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The scaled graphic.
<Object> info

The info object has the following properties:


{

  transform: <Object>,

  scaleX: <Number>,

  scaleY: <Number>,

  around: <Object>

}

Sample:
require([
 ... 
], function( ... ) {
  editToolbar.on('scale-stop',function(evt){
    var info = evt.info;
    var around = info.around;  //height,width,x,y
    var transform = info.transform; //dx,dy,xx,xy,yx,yy
    var scalex = info.scaleX;
    var scaley = info.scaleY;
  });
  ...
});

vertex-add

Fired after a new vertex is added to a polyline or polygon or a new point is added to a multipoint. Applicable only when the EDIT_VERTICES tool is active. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The graphic associated with the toolbar.
<Object> vertexinfo See the object specifications table below for the structure of the vertexinfo object.
Object Specifications:
<vertexinfo>
<Boolean> isGhost Specifies whether the event fired for an existing vertex or a ghost vertex. When true, pointIndex indicates the position the vertex will take when added to the graphic.
<Number> pointIndex Index of the vertex in the segment indicated by segmentIndex.
<Number> segmentIndex Index of the ring or path that contains the vertex. Always 0 for multipoints.

vertex-click

Fired when the mouse button is clicked on the vertex of a polyline or polygon or a point in a multipoint. Applicable only when the EDIT_VERTICES tool is active. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The graphic associated with the toolbar.
<Object> vertexinfo See the object specifications table below for the structure of the vertexinfo object.
Object Specifications:
<vertexinfo>
<Boolean> isGhost Specifies whether the event fired for an existing vertex or a ghost vertex. When true, pointIndex indicates the position the vertex will take when added to the graphic.
<Number> pointIndex Index of the vertex in the segment indicated by segmentIndex.
<Number> segmentIndex Index of the ring or path that contains the vertex. Always 0 for multipoints.

vertex-delete

Fired after a vertex(polyline, polygon) or point(multipoint) is deleted. Applicable only when the EDIT_VERTICES tool is active. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The graphic associated with the toolbar.
<Object> vertexinfo See the object specifications table below for the structure of the vertexinfo object.
Object Specifications:
<vertexinfo>
<Boolean> isGhost Specifies whether the event fired for an existing vertex or a ghost vertex. When true, pointIndex indicates the position the vertex will take when added to the graphic.
<Number> pointIndex Index of the vertex in the segment indicated by segmentIndex.
<Number> segmentIndex Index of the ring or path that contains the vertex. Always 0 for multipoints.

vertex-first-move

Fired when the user begins to move the vertex of a polyline or polygon or a point of a multipoint. Applicable only when the EDIT_VERTICES tool is active. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The graphic associated with the toolbar.
<Object> vertexinfo See the object specifications table below for the structure of the vertexinfo object.
Object Specifications:
<vertexinfo>
<Boolean> isGhost Specifies whether the event fired for an existing vertex or a ghost vertex. When true, pointIndex indicates the position the vertex will take when added to the graphic.
<Number> pointIndex Index of the vertex in the segment indicated by segmentIndex.
<Number> segmentIndex Index of the ring or path that contains the vertex. Always 0 for multipoints.

vertex-mouse-out

Fires as the mouse exits a vertex(polyline, polygon) or a point(multipoint). Applicable only when the EDIT_VERTICES tool is active. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The graphic associated with the toolbar.
<Object> vertexinfo See the object specifications table below for the structure of the vertexinfo object.
Object Specifications:
<vertexinfo>
<Boolean> isGhost Specifies whether the event fired for an existing vertex or a ghost vertex. When true, pointIndex indicates the position the vertex will take when added to the graphic.
<Number> pointIndex Index of the vertex in the segment indicated by segmentIndex.
<Number> segmentIndex Index of the ring or path that contains the vertex. Always 0 for multipoints.

vertex-mouse-over

Fired when the mouse moves over a vertex (polyline, polygon) or point (multipoint). Applicable only when the EDIT_VERTICES tool is active. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The graphic associated with the toolbar.
<Object> vertexinfo See the object specifications table below for the structure of the vertexinfo object.
Object Specifications:
<vertexinfo>
<Boolean> isGhost Specifies whether the event fired for an existing vertex or a ghost vertex. When true, pointIndex indicates the position the vertex will take when added to the graphic.
<Number> pointIndex Index of the vertex in the segment indicated by segmentIndex.
<Number> segmentIndex Index of the ring or path that contains the vertex. Always 0 for multipoints.

vertex-move

Fired continuously as the user is moving a vertex (polyline, polygon) or point (multipoint). Applicable only when the EDIT_VERTICES tool is active. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The graphic associated with the toolbar.
<Object> transform Represents the linear transformation applied to the graphic.
<Object> vertexinfo See the object specifications table below for the structure of the vertexinfo object.
Object Specifications:
<vertexinfo>
<Boolean> isGhost Specifies whether the event fired for an existing vertex or a ghost vertex. When true, pointIndex indicates the position the vertex will take when added to the graphic.
<Number> pointIndex Index of the vertex in the segment indicated by segmentIndex.
<Number> segmentIndex Index of the ring or path that contains the vertex. Always 0 for multipoints.

vertex-move-start

Fired when the mouse button is pressed down on a vertex (polyline, polygon) or point (multipoint). Applicable only when the EDIT_VERTICES tool is active. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The graphic associated with the toolbar.
<Object> vertexinfo See the object specifications table below for the structure of the vertexinfo object.
Object Specifications:
<vertexinfo>
<Boolean> isGhost Specifies whether the event fired for an existing vertex or a ghost vertex. When true, pointIndex indicates the position the vertex will take when added to the graphic.
<Number> pointIndex Index of the vertex in the segment indicated by segmentIndex.
<Number> segmentIndex Index of the ring or path that contains the vertex. Always 0 for multipoints.

vertex-move-stop

Fired when the mouse button is released from a vertex (polyline, polygon) or point(multipoint). Applicable only when the EDIT_VERTICES tool is active. (Added at v3.6)
Event Object Properties:
<Graphic> graphic The graphic associated with the toolbar.
<Object> transform Represents the linear transformation applied to the graphic.
<Object> vertexinfo See the object specifications table below for the structure of the vertexinfo object.
Object Specifications:
<vertexinfo>
<Boolean> isGhost Specifies whether the event fired for an existing vertex or a ghost vertex. When true, pointIndex indicates the position the vertex will take when added to the graphic.
<Number> pointIndex Index of the vertex in the segment indicated by segmentIndex.
<Number> segmentIndex Index of the ring or path that contains the vertex. Always 0 for multipoints.
Show Modal