Note: This is an EB 1.7 Widget (not backward compatible).
Live Preview Site
Details:
- The widget allows you to draw in a 2D map view.
- You can edit graphics that you have drawn (symbology and geometry).
- You can draw points, lines, polygons, text
To install this widget extract the contents of the zip file to your EB\client\your-extensions\widgets. So once you extract the whole path would look like: \client\your-extensions\widgets\draw. Refresh your client and server windows (easiest way is to close both and 'npm start' them like you normally do to start EB). Now the draw widget will appear in your apps widget menu. Add the widget to your app. Now use the widgets settings panel to configure the widget.
This widget requires an edit to the client\types\arcgis-js-api.d.ts file.
You must add:
....
interface SketchViewModel extends Accessor, Evented {
....
canUndo(): boolean;
canRedo(): boolean;
...
So the complete portion of the changed file will look like this:
interface SketchViewModel extends Accessor, Evented {
/**
* The [SimpleFillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html) displayed when actively creating a new `polygon` graphic using the [`polygon`](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#activeTool) tool.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#activeFillSymbol)
*/
activeFillSymbol: SimpleFillSymbol;
/**
* When creating new graphics (for example after [create()](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#create) has been called), this property reflects the create tool being used.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#activeTool)
*/
readonly activeTool:
| "point"
| "multipoint"
| "polyline"
| "polygon"
| "circle"
| "rectangle"
| "move"
| "transform"
| "reshape";
/**
* The graphic that is being created.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#createGraphic)
*/
readonly createGraphic: Graphic;
/**
* Default create options set for the SketchViewModel.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#defaultCreateOptions)
*/
defaultCreateOptions: SketchViewModelDefaultCreateOptions;
/**
* Default update options set for the SketchViewModel.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#defaultUpdateOptions)
*/
defaultUpdateOptions: SketchViewModelDefaultUpdateOptions;
/**
* The [GraphicsLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html) associated with the SketchViewModel.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#layer)
*/
layer: GraphicsLayer;
/**
* A [SimpleMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html), [PointSymbol3D](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html), [TextSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html), [CIMSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-CIMSymbol.html), or [WebStyleSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html) used for representing the point geometry that is being drawn.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#pointSymbol)
*/
pointSymbol: SimpleMarkerSymbol | PointSymbol3D | TextSymbol | CIMSymbol | WebStyleSymbol;
/**
* A [SimpleFillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html), [PolygonSymbol3D](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PolygonSymbol3D.html), or [CIMSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-CIMSymbol.html) used for representing the polygon geometry that is being drawn.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#polygonSymbol)
*/
polygonSymbol: SimpleFillSymbol | PolygonSymbol3D | CIMSymbol;
/**
* A [SimpleLineSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html), [LineSymbol3D](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3D.html), or [CIMSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-CIMSymbol.html) used for representing the polyline geometry that is being drawn.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#polylineSymbol)
*/
polylineSymbol: SimpleLineSymbol | LineSymbol3D | CIMSymbol;
/**
* The [SnappingOptions](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-interactive-snapping-SnappingOptions.html) for sketching.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#snappingOptions)
*/
snappingOptions: SnappingOptions;
/**
* The sketch view model's state.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#state)
*/
readonly state: "ready" | "disabled" | "active";
/**
* An array of graphics that are being updated by the SketchViewModel.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#updateGraphics)
*/
readonly updateGraphics: Collection<Graphic>;
/**
* Indicates if a graphic can be selected to be updated.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#updateOnGraphicClick)
*/
updateOnGraphicClick: boolean;
/**
* The view in which geometries will be sketched by the user.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#view)
*/
view: MapView | SceneView;
/**
* Cancels the active operation and fires the [create](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#event-create) or [update](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#event-update) event If called in the middle of a create operation, `cancel()` discards the partially created graphic.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#cancel)
*/
cancel(): void;
/**
* Completes the active operation and fires the [create](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#event-create) or [update](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#event-update) event and changes the event's state to `complete`.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#complete)
*/
complete(): void;
canUndo(): boolean;
canRedo(): boolean;
/**
* Create a graphic with the geometry specified in the `tool` parameter.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#create)
*/
create(
tool: "point" | "multipoint" | "polyline" | "polygon" | "rectangle" | "circle",
createOptions?: SketchViewModelCreateCreateOptions
😞 void;
/**
* Deletes the selected graphics used in the update workflow.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#delete)
*/
delete(): void;
/**
* Destroys the view model instance.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#destroy)
*/
destroy(): void;
/**
* Incrementally redo actions recorded in the stack.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#redo)
*/
redo(): void;
/**
* Incrementally undo actions recorded in the stack.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#undo)
*/
undo(): void;
/**
* Initializes an update operation for the specified graphic(s) and fires [update](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#event-update) event.
*
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#update)
*/
update(graphics: Graphic | Graphic[], updateOptions?: SketchViewModelUpdateUpdateOptions): Promise<void>;
on(name: "delete", eventHandler: SketchViewModelDeleteEventHandler): IHandle;
on(name: "create", eventHandler: SketchViewModelCreateEventHandler): IHandle;
on(name: "update", eventHandler: SketchViewModelUpdateEventHandler): IHandle;
on(name: "redo", eventHandler: SketchViewModelRedoEventHandler): IHandle;
on(name: "undo", eventHandler: SketchViewModelUndoEventHandler): IHandle;
}
Lines 108 and 109 added.
Enjoy, Robert