require(["esri/toolbars/edit"], function(Edit) { /* code goes here */ });
Name | Summary |
---|---|
new Edit(map, options?) | Creates a new Edit object. |
Name | Description |
---|---|
EDIT_TEXT | When 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:
|
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 |
Name | Return type | Summary | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
activate(tool, graphic, options?) | None | Activates the toolbar to edit the supplied graphic. | ||||||||
deactivate() | None | Deactivates the toolbar. | ||||||||
getCurrentState() | Object | An object with the following properties that describe the current state.
| ||||||||
refresh() | None | Refreshes the internal state of the toolbar. |
Name | Event Object | Summary |
---|---|---|
activate | { graphic: < | Activates the toolbar for editing geometries. |
deactivate | { graphic: < | Deactivates the toolbar and reactivates map navigation. |
graphic-click | { graphic: < | Fires when a graphic is clicked. |
graphic-first-move | {
graphic: < | Fires when the user begins to move a graphic. |
graphic-move | { graphic: < | Fired continuously as the graphic moves. |
graphic-move-start | {
graphic: < | Fired when the mouse button is pressed down on the graphic, usually while moving a graphic. |
graphic-move-stop | { graphic: < | Fired when the mouse button is released, usually after moving the graphic. |
rotate | { graphic: < | Fires continuously as a graphic is rotated. |
rotate-first-move | {
graphic: < | Fires when the user begins to drag a handle to rotate the graphic. |
rotate-start | {
graphic: < | Fires when a user clicks on the handle to begin rotating a graphic. |
rotate-stop | { graphic: < | Fires when the mouse button is released from the rotate handle to finish rotating the graphic. |
scale | { graphic: < | Fires continuously as the graphic is being scaled. |
scale-first-move | {
graphic: < | Fires when the user begins to drag a handle to scale the graphic. |
scale-start | {
graphic: < | Fires when a user clicks on the handle to scale or resize a graphic. |
scale-stop | { graphic: < | Fires when the mouse button is released from the scale handle to finish scaling the graphic. |
vertex-add | { graphic: < | Fired after a new vertex is added to a polyline or polygon or a new point is added to a multipoint. |
vertex-click | { graphic: < | Fired when the mouse button is clicked on the vertex of a polyline or polygon or a point in a multipoint. |
vertex-delete | { graphic: < | Fired after a vertex(polyline, polygon) or point(multipoint) is deleted. |
vertex-first-move | { graphic: < | Fired when the user begins to move the vertex of a polyline or polygon or a point of a multipoint. |
vertex-mouse-out | { graphic: < | Fires as the mouse exits a vertex(polyline, polygon) or a point(multipoint). |
vertex-mouse-over | { graphic: < | Fired when the mouse moves over a vertex (polyline, polygon) or point (multipoint). |
vertex-move | { graphic: < | Fired continuously as the user is moving a vertex (polyline, polygon) or point (multipoint). |
vertex-move-start | { graphic: < | Fired when the mouse button is pressed down on a vertex (polyline, polygon) or point (multipoint). |
vertex-move-stop | { graphic: < | Fired when the mouse button is released from a vertex (polyline, polygon) or point(multipoint). |
< > map |
Required | Map the toolbar is associated with. |
< > options |
Optional | Optional parameters. See options list. |
options
properties: < > allowAddVertices |
Optional | Specifies whether users can add new vertices. Valid for polyline and polygon geometries. |
< > allowDeleteVertices |
Optional | Specifies whether users can delete vertices. Valid for polyline, polygon and multipoint geometries. |
< > ghostLineSymbol |
Optional | Line symbol used to draw the guild lines, displayed when moving vertices. Valid for polyline and polygon geometries. |
< > ghostVertexSymbol |
Optional | Marker symbol used to display the insertable vertices. Valid for polyline and polygon geometries. |
< > textSymbolEditorHolder |
Optional | If users want to place the text symbol editor to a user defined HTML element. |
< > uniformScaling |
Optional | When true, if the geometry is re-sized the aspect ration will be preserved. |
< > vertexSymbol |
Optional | Marker symbol used to draw the vertices. Valid for polyline and polygon geometries. |
< > tool |
Required | Specify the active tool(s). Combine tools using the | operator. See the Constants table for a list of valid values. |
< > graphic |
Required | The graphic to edit. |
< > options |
Optional | See the object specifications table below for the structure of the options object.
|
options
>< > allowAddVertices |
Optional | Specifies whether users can add new vertices. Valid geometry: Polyline, Polygon |
< > allowDeleteVertices |
Optional | Specifies whether users can delete vertices. Valid geometry: Polygon, Polygon, Multipoint |
< > boxHandleSymbol |
Optional | Symbol to use when rotating or scaling geometries. |
< > boxLineSymbol |
Optional | Symbol for guide lines, displayed when rotating or moving geometries. |
< > ghostLineSymbol |
Optional | Symbol for guide lines, displayed when moving vertices |
< > ghostVertexSymbol |
Optional | Symbol for insertable vertices |
< > textSymbolEditorHolder |
Optional | Specifies whether users should place the text symbol editor to a user defined HTML element |
< > uniformScaling |
Optional | Specifies whether the geometry is resized if the aspect ratio will be preserved. |
< > vertexSymbol |
Optional | Symbol for vertices |
require([ "esri/toolbars/edit", ... ], function(Edit, ... ) { var editToolbar = new Edit( ... ); //Use the edit toolbar to edit vertices editToolbar.activate(Edit.EDIT_VERTICES , evt.graphic); ... }); require([ "esri/toolbars/edit", ... ], function(Edit, ... ) { var editToolbar = new Edit( ... ); //Combine tools editToolbar.activate(Edit.MOVE | Edit.SCALE, evt.graphic); ... });
editToolbar.deactivate();
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. |
Object
< > graphic |
The graphic the toolbar was associated with. |
< > info |
The info object has the following properties: { isModified:<Boolean> } |
< > tool |
The editing type. The Constants table lists valid editing values. |
require([ ... ], function( ... ) { editToolbar.on("deactivate", function(evt) { if(evt.info.isModified){ firePerimeterFL.applyEdits(null, [evt.graphic], null); } }); ... });
< > graphic |
The graphic associated with the toolbar. |
< > graphic |
The graphic associated with the toolbar. |
< > graphic |
The rotated graphic. |
< > info |
The info object has the following properties: { transform: <Object>, angle: <Number> around: <Object> } |
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 }); ... });
< > graphic |
The rotated graphic. |
require([ ... ], function( ... ) { editToolbar.on('rotate-first-move',function(evt){ console.log('Rotating'); }); ... });
< > graphic |
The rotated graphic. |
require([ ... ], function( ... ) { editToolbar.on('rotate-start',function(evt){ console.log('Start Rotating'); }); ... });
< > graphic |
The rotated graphic. |
< > info |
The info object has the following properties: { transform: <Object>, angle: <Number> around: <Object> } |
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 }); ... });
< > graphic |
The scaled graphic. |
< > info |
The info object has the following properties: { transform: <Object>, scaleX: <Number>, scaleY: <Number>, around: <Object> } |
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; }); ... });
< > graphic |
The scaled graphic. |
require([ ... ], function( ... ) { editToolbar.on('scale-first-move',function(evt){ console.log('Begin Scaling'); }); ... });
< > graphic |
The scaled graphic. |
require([ ... ], function( ... ) { editToolbar.on('scale-start',function(evt){ console.log('Scaling Started'); }); ... });
< > graphic |
The scaled graphic. |
< > info |
The info object has the following properties: { transform: <Object>, scaleX: <Number>, scaleY: <Number>, around: <Object> } |
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; }); ... });
< > graphic |
The graphic associated with the toolbar. |
< > vertexinfo |
See the object specifications table below for the structure of the vertexinfo object. |
vertexinfo
>< > 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. |
< > pointIndex |
Index of the vertex in the segment indicated by segmentIndex . |
< > segmentIndex |
Index of the ring or path that contains the vertex. Always 0 for multipoints. |
< > graphic |
The graphic associated with the toolbar. |
< > vertexinfo |
See the object specifications table below for the structure of the vertexinfo object. |
vertexinfo
>< > 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. |
< > pointIndex |
Index of the vertex in the segment indicated by segmentIndex . |
< > segmentIndex |
Index of the ring or path that contains the vertex. Always 0 for multipoints. |
< > graphic |
The graphic associated with the toolbar. |
< > vertexinfo |
See the object specifications table below for the structure of the vertexinfo object. |
vertexinfo
>< > 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. |
< > pointIndex |
Index of the vertex in the segment indicated by segmentIndex . |
< > segmentIndex |
Index of the ring or path that contains the vertex. Always 0 for multipoints. |
< > graphic |
The graphic associated with the toolbar. |
< > vertexinfo |
See the object specifications table below for the structure of the vertexinfo object. |
vertexinfo
>< > 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. |
< > pointIndex |
Index of the vertex in the segment indicated by segmentIndex . |
< > segmentIndex |
Index of the ring or path that contains the vertex. Always 0 for multipoints. |
< > graphic |
The graphic associated with the toolbar. |
< > vertexinfo |
See the object specifications table below for the structure of the vertexinfo object. |
vertexinfo
>< > 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. |
< > pointIndex |
Index of the vertex in the segment indicated by segmentIndex . |
< > segmentIndex |
Index of the ring or path that contains the vertex. Always 0 for multipoints. |
< > graphic |
The graphic associated with the toolbar. |
< > vertexinfo |
See the object specifications table below for the structure of the vertexinfo object. |
vertexinfo
>< > 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. |
< > pointIndex |
Index of the vertex in the segment indicated by segmentIndex . |
< > segmentIndex |
Index of the ring or path that contains the vertex. Always 0 for multipoints. |
< > graphic |
The graphic associated with the toolbar. |
< > transform |
Represents the linear transformation applied to the graphic. |
< > vertexinfo |
See the object specifications table below for the structure of the vertexinfo object. |
vertexinfo
>< > 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. |
< > pointIndex |
Index of the vertex in the segment indicated by segmentIndex . |
< > segmentIndex |
Index of the ring or path that contains the vertex. Always 0 for multipoints. |
< > graphic |
The graphic associated with the toolbar. |
< > vertexinfo |
See the object specifications table below for the structure of the vertexinfo object. |
vertexinfo
>< > 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. |
< > pointIndex |
Index of the vertex in the segment indicated by segmentIndex . |
< > segmentIndex |
Index of the ring or path that contains the vertex. Always 0 for multipoints. |
< > graphic |
The graphic associated with the toolbar. |
< > transform |
Represents the linear transformation applied to the graphic. |
< > vertexinfo |
See the object specifications table below for the structure of the vertexinfo object. |
vertexinfo
>< > 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. |
< > pointIndex |
Index of the vertex in the segment indicated by segmentIndex . |
< > segmentIndex |
Index of the ring or path that contains the vertex. Always 0 for multipoints. |