Description
Class added v2.0.dojo.require("esri.toolbars.edit"); 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.
Class hierarchy
esri.toolbars.Edit
Constructor
Constants
| 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 polyong, last two points in a line, and last point in a multipoint cannot be deleted.
| 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 |
|
| MOVE |
Move graphic to a new location on the map. Applicable to Point, Polyline, or Polygon. |
| ROTATE |
Rotate the graphic. As of version 2.1. |
| SCALE |
Scale or resize a graphic. As of version 2.1 |
Methods
| activate(tool, graphic, options?) |
none
|
Activates the toolbar to edit the supplied graphic. |
| deactivate() |
none
|
Deactivates the toolbar. Call this method to deactivate the toolbar after editing the graphic. |
| getCurrentState() |
Object
|
An object with the following properties that describe the current state.
| Value |
Description |
| <Number> tool |
Indicates if the tool is currently being used. 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() |
none
|
Refreshes the internal state of the toolbar. |
Events
| onActivate(tool, graphic)
|
Activates the toolbar for editing geomtries. Activating the toolbar disables map navigation. |
| onDeactivate(tool, graphic, info)
|
Deactivates the toolbar and reactivates map navigation. |
| onGraphicClick(graphic, info)
|
Fires when a graphic is clicked. Applicable only when the MOVE tool is active. |
| onGraphicFirstMove(graphic)
|
Fires when the user begins to move a graphic. Applicable only when the MOVE tool is active. |
| onGraphicMove(graphic, transform)
|
Fired continuously as the graphic moves. Applicable only when the MOVE tool is active. |
| onGraphicMoveStart(graphic)
|
Fired when the mouse button is pressed down on the graphic, usually while moving a graphic. Applicable only when the MOVE tool is active. |
| onGraphicMoveStop(graphic, transform)
|
Fired when the mouse button is released, usually after moving the graphic. Applicable only when the MOVE tool is active. |
| onRotate(graphic, info)
|
Fires continuously as a graphic is rotated. |
| onRotateFirstMove(graphic)
|
Fires when the user begins to drag a handle to rotate the graphic. |
| onRotateStart(graphic)
|
Fires when a user clicks on the handle to begin rotating a graphic. |
| onRotateStop(graphic, info)
|
Fires when the mouse button is released from the rotate handle to finish rotating the graphic. |
| onScale(graphic, info)
|
Fires continuously as the graphic is being scaled. |
| onScaleFirstMove(graphic)
|
Fires when the user begins to drag a handle to scale the graphic. |
| onScaleStart(graphic)
|
Fires when a user clicks on the handle to scale or resize a graphic. |
| onScaleStop(graphic, info)
|
Fires when the mouse button is released from the scale handle to finish scaling the graphic. |
| onVertexAdd(graphic, vertexInfo)
|
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. |
| onVertexClick(graphic, vertexInfo)
|
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. |
| onVertexDelete(graphic, vertexInfo)
|
Fired after a vertex(polyline, polygon) or point(multipoint) is deleted. Applicable only when the EDIT_VERTICES tool is active. |
| onVertexFirstMove(graphic, vertexInfo)
|
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. |
| onVertexMouseOut(graphic, vertexInfo)
|
Fires as the mouse exits a vertex(polyline,polygon) or a point(multipoint). Applicable only when the EDIT_VERTICES tool is active. |
| onVertexMouseOver(graphic, vertexInfo)
|
Fired when the mouse moves over a vertex (polyline,polygon) or point (multipoint). Applicable only when the EDIT_VERTICES tool is active. |
| onVertexMove(graphic, vertexInfo, transform)
|
Fired continuously as the user is moving a vertex (polyline, polygon) or point (multipoint). Applicable only when the EDIT_VERTICES tool is active. |
| onVertexMoveStart(graphic, vertexInfo)
|
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. |
| onVertexMoveStop(graphic, vertexInfo, transform)
|
Fired when the mouse button is released from a vertex (polyline, polygon) or point(multipoint). Applicable only when the EDIT_VERTICES tool is active. |
Constructor Detail
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:
|
<Boolean>
allowAddVertices |
Specifies whether users can add new vertices. Valid for polyline and polygon geometries.
|
|
<Boolean>
allowDeletevertices |
Specifies whether users can delete vertices. Valid for polyline, polygon and multipoint geometries.
|
|
<LineSymbol>
ghostLineSymbol |
Line symbol used to draw the guild lines, displayed when moving vertices. Valid for polyline and polygon geometries.
|
|
<MarkerSymbol>
ghostVertexSymbol |
Marker symbol used to display the insertable vertices. Valid for polyline and polygon geometries.
|
|
<MarkerSymbol>
vertexSymbol |
Marker symbol used to draw the vertices. Valid for polyline and polygon geometries.
|
Code snippets:
editToolbar = new esri.toolbars.Edit(map);
Methods Detail
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.
Return value: none
Input Parameters:
|
<String> tool |
Required |
The following are valid options, see the Constants table for more details.
| Constant |
Description |
| esri.toolbars.Edit.MOVE |
The graphic can be moved. |
| esri.toolbars.Edit.EDIT_VERTICES |
The vertices can be edited. |
| esri.toolbars.Edit.MOVE | esri.toolbars.Edit.EDIT_VERTICES |
Graphics can be moved and the vertices are editable. |
|
|
<Graphic> graphic |
Required |
The graphic to edit. |
|
<Object> options |
Optional |
The following properties are valid options:
|
Code snippets:
editToolbar.activate(esri.toolbars.Edit.EDIT_VERTICES , evt.graphic);
Deactivates the toolbar. Call this method to deactivate the toolbar after editing the graphic.
Return value: none
Code snippets:
editToolbar.deactivate();
An object with the following properties that describe the current state.
| Value |
Description |
| <Number> tool |
Indicates if the tool is currently being used. 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 value: Object
Refreshes the internal state of the toolbar.
Return value: none
Events Detail
onActivate(tool, graphic)
Activates the toolbar for editing geomtries. Activating the toolbar disables map navigation.
Arguments:
|
<String> tool
|
The editing type. The Constants table lists valid editing values.
|
|
<Graphic> graphic
|
The graphic to edit whose vertices will be edited or moved.
|
onDeactivate(tool, graphic, info)
Deactivates the toolbar and reactivates map navigation.
Arguments:
|
<String> tool
|
The editing type. The Constants table lists valid editing values.
|
|
<Graphic> graphic
|
The graphic the toolbar was associated with.
|
|
<Object> info
|
The info object has the following properties:
{
isModified:<Boolean>
}
|
Code snippets:
dojo.connect(editToolbar, "onDeactivate", function(tool,graphic,info) {
if(info.isModified){
firePerimeterFL.applyEdits(null, [graphic], null);
}
});
onGraphicClick(graphic, info)
Fires when a graphic is clicked. Applicable only when the MOVE tool is active.
Arguments:
|
<Graphic> graphic
|
The clicked graphic.
|
|
<Object> info
|
Object with the following properties:
|
<Point screenPoint
|
Location of mouse click in screen coordinates (pixels).
|
|
<Point mapPoint
|
Location of mouse click in map coordinates.
|
|
onGraphicFirstMove(graphic)
Fires when the user begins to move a graphic. Applicable only when the MOVE tool is active.
Arguments:
|
<Graphic> graphic
|
The graphic associated with the toolbar.
|
onGraphicMove(graphic, transform)
Fired continuously as the graphic moves. Applicable only when the MOVE tool is active.
Arguments:
|
<Graphic> graphic
|
The graphic associated with the toolbar.
|
|
<Object> transform
|
Represents the linear transformation applied to the graphic.
|
onGraphicMoveStart(graphic)
Fired when the mouse button is pressed down on the graphic, usually while moving a graphic. Applicable only when the MOVE tool is active.
Arguments:
|
<Graphic> graphic
|
The graphic associated with the toolbar.
|
onGraphicMoveStop(graphic, transform)
Fired when the mouse button is released, usually after moving the graphic. Applicable only when the MOVE tool is active.
Arguments:
|
<Graphic> graphic
|
The graphic associated with the toolbar.
|
|
<Object> transform
|
Represents the linear transformation applied to the graphic.
|
Fires continuously as a graphic is rotated. (As of v2.1)
Arguments:
|
<Graphic> graphic
|
The rotated graphic.
|
|
<Object> info
|
The info object has the following properties:
{
transform: <Object>,
angle: <Number>
around: <Object>
}
|
Code snippets:
dojo.connect(editToolbar,'onRotate',function(graphic,info){
var around = info.around; //x,y,scalex,scaley
var angle = info.angle;
var transform = info.transform //dx,dy,xx,xy,yx,yy
});
onRotateFirstMove(graphic)
Fires when the user begins to drag a handle to rotate the graphic. (As of v2.1)
Arguments:
|
<Graphic> graphic
|
The rotated graphic.
|
Code snippets:
dojo.connect(editToolbar,'onRotateFirstMove',function(graphic){
console.log('Rotating');
});
Fires when a user clicks on the handle to begin rotating a graphic. (As of v2.1)
Arguments:
|
<Graphic> graphic
|
The rotated graphic.
|
Code snippets:
dojo.connect(editToolbar,'onRotateStart',function(graphic){
console.log('Start Rotating');
});
onRotateStop(graphic, info)
Fires when the mouse button is released from the rotate handle to finish rotating the graphic. (As of v2.1)
Arguments:
|
<Graphic> graphic
|
The rotated graphic.
|
|
<Object> info
|
The info object has the following properties:
{
transform: <Object>,
angle: <Number>
around: <Object>
}
|
Code snippets:
dojo.connect(editToolbar,'onRotateStop',function(graphic,info){
var around = info.around; //x,y,scalex,scaley
var angle = info.angle;
var transform = info.transform //dx,dy,xx,xy,yx,yy
});
Fires continuously as the graphic is being scaled.
(As of v2.1)
Arguments:
|
<Graphic> graphic
|
The scaled graphic.
|
|
<Object> info
|
The info object has the following properties:
{
transform: <Object>,
scaleX: <Number>,
scaleY: <Number>,
around: <Object>
}
|
Code snippets:
dojo.connect(editToolbar,'onScale',function(graphic,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;
});
onScaleFirstMove(graphic)
Fires when the user begins to drag a handle to scale the graphic. (As of v2.1)
Arguments:
|
<Graphic> graphic
|
The scaled graphic.
|
Code snippets:
dojo.connect(editToolbar,'onScaleFirstMove',function(graphic){
console.log('Begin Scaling');
});
Fires when a user clicks on the handle to scale or resize a graphic. (As of v2.1)
Arguments:
|
<Graphic> graphic
|
The scaled graphic.
|
Code snippets:
dojo.connect(editToolbar,'onScaleStart',function(graphic){
console.log('Scaling Started');
});
onScaleStop(graphic, info)
Fires when the mouse button is released from the scale handle to finish scaling the graphic. (As of v2.1)
Arguments:
|
<Graphic> graphic
|
The scaled graphic.
|
|
<Object> info
|
The info object has the following properties:
{
transform: <Object>,
scaleX: <Number>,
scaleY: <Number>,
around: <Object>
}
|
Code snippets:
dojo.connect(editToolbar,'onScaleStop',function(graphic,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;
});
onVertexAdd(graphic, vertexInfo)
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.
Arguments:
|
<Graphic> graphic
|
The graphic associated with the toolbar.
|
|
<Object> vertexInfo
|
The vertexInfo object has the following properties
|
<Number> segmentIndex
|
Index of the ring or path that contains the vertex. Always 0 for multipoints.
|
|
<Number> pointIndex
|
Index of the vertex in the segment indicated by segmentIndex.
|
|
<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.
|
|
onVertexClick(graphic, vertexInfo)
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.
Arguments:
|
<Graphic> graphic
|
The graphic associated with the toolbar.
|
|
<Object> vertexInfo
|
The vertexInfo object has the following properties
|
<Number> segmentIndex
|
Index of the ring or path that contains the vertex. Always 0 for multipoints.
|
|
<Number> pointIndex
|
Index of the vertex in the segment indicated by segmentIndex.
|
|
<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.
|
|
onVertexDelete(graphic, vertexInfo)
Fired after a vertex(polyline, polygon) or point(multipoint) is deleted. Applicable only when the EDIT_VERTICES tool is active.
Arguments:
|
<Graphic> graphic
|
The graphic associated with the toolbar.
|
|
<Object> vertexInfo
|
The vertexInfo object has the following properties
|
<Number> segmentIndex
|
Index of the ring or path that contains the vertex. Always 0 for multipoints.
|
|
<Number> pointIndex
|
Index of the vertex in the segment indicated by segmentIndex.
|
|
<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.
|
|
onVertexFirstMove(graphic, vertexInfo)
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.
Arguments:
|
<Graphic> graphic
|
The graphic associated with the toolbar.
|
|
<Object> vertexInfo
|
The vertexInfo object has the following properties
|
<Number> segmentIndex
|
Index of the ring or path that contains the vertex. Always 0 for multipoints.
|
|
<Number> pointIndex
|
Index of the vertex in the segment indicated by segmentIndex.
|
|
<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.
|
|
onVertexMouseOut(graphic, vertexInfo)
Fires as the mouse exits a vertex(polyline,polygon) or a point(multipoint). Applicable only when the EDIT_VERTICES tool is active.
Arguments:
|
<Graphic> graphic
|
The graphic associated with the toolbar.
|
|
<Object> vertexInfo
|
The vertexInfo object has the following properties
|
<Number> segmentIndex
|
Index of the ring or path that contains the vertex. Always 0 for multipoints.
|
|
<Number> pointIndex
|
Index of the vertex in the segment indicated by segmentIndex.
|
|
<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.
|
|
onVertexMouseOver(graphic, vertexInfo)
Fired when the mouse moves over a vertex (polyline,polygon) or point (multipoint). Applicable only when the EDIT_VERTICES tool is active.
Arguments:
|
<Graphic> graphic
|
The graphic associated with the toolbar.
|
|
<Object> vertexInfo
|
The vertexInfo object has the following properties
|
<Number> segmentIndex
|
Index of the ring or path that contains the vertex. Always 0 for multipoints.
|
|
<Number> pointIndex
|
Index of the vertex in the segment indicated by segmentIndex.
|
|
<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.
|
|
onVertexMove(graphic, vertexInfo, transform)
Fired continuously as the user is moving a vertex (polyline, polygon) or point (multipoint). Applicable only when the EDIT_VERTICES tool is active.
Arguments:
|
<Graphic> graphic
|
The graphic associated with the toolbar.
|
|
<Object> vertexInfo
|
The vertexInfo object has the following properties
|
<Number> segmentIndex
|
Index of the ring or path that contains the vertex. Always 0 for multipoints.
|
|
<Number> pointIndex
|
Index of the vertex in the segment indicated by segmentIndex.
|
|
<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.
|
|
|
<Object> transform
|
Represents the linear transformation applied to the graphic.
|
onVertexMoveStart(graphic, vertexInfo)
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.
Arguments:
|
<Graphic> graphic
|
The graphic associated with the toolbar.
|
|
<Object> vertexInfo
|
The vertexInfo object has the following properties
|
<Number> segmentIndex
|
Index of the ring or path that contains the vertex. Always 0 for multipoints.
|
|
<Number> pointIndex
|
Index of the vertex in the segment indicated by segmentIndex.
|
|
<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.
|
|
onVertexMoveStop(graphic, vertexInfo, transform)
Fired when the mouse button is released from a vertex (polyline, polygon) or point(multipoint). Applicable only when the EDIT_VERTICES tool is active.
Arguments:
|
<Graphic> graphic
|
The graphic associated with the toolbar.
|
|
<Object> vertexInfo
|
The vertexInfo object has the following properties
|
<Number> segmentIndex
|
Index of the ring or path that contains the vertex. Always 0 for multipoints.
|
|
<Number> pointIndex
|
Index of the vertex in the segment indicated by segmentIndex.
|
|
<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.
|
|
|
<Object> transform
|
Represents the linear transformation applied to the graphic.
|