import { Mutable } from 'apprt-core/Mutable'; import Graphic from '@arcgis/core/Graphic'; import { View } from 'map-widget/api'; import { SymbolUnion } from '@arcgis/core/unionTypes'; /** * Draws a graphic on the map. * * Reference "mapdraw-api.DefaultMapDrawing" to inject the default instance of this interface. */ type Drawing = Mutable; /** * Fields usable on {@link Drawing}. */ interface DrawingMembers { /** * The view to draw on. */ view: View; /** * The current drawing mode */ mode: DrawingMode; /** * The current vertex mode. */ vertexMode?: VertexMode; /** * Lookup object for symbols used while drawing. * * It has the following structure: * ``` * { * "rectangle": { * type: "simple-fill", * color: [0, 0, 0, 0.25], * style: "solid", * outline: { * color: "#FF0000", * width: 2 * } * }, * "polygon": { * type: "simple-fill", * color: [0, 0, 0, 0.25], * style: "solid", * outline: { * color: "#FF0000", * width: 2 * } * }, * "polyline": { * type: "simple-line", * style: "solid", * color: "#FF0000", * width: 2 * }, * "point": { * type: "simple-marker", * style: "circle", * color: [0, 0, 0, 0.25], * size: "2px", * outline: { * color: "#FF0000", * width: 2 * } * } * } * ``` */ symbols: SymbolLookup; /** * Actives (or deactivates) drawing on the map. */ active: boolean; /** * If drawing has finished, the drawn graphic will be provided here. */ readonly graphic: Graphic | undefined; } /** * Options supported when creating a new {@link Drawing} instance. */ interface DrawingOptions { /** * The view to draw on. */ view: View; /** * The drawing mode. Defaults to `"rectangle"`. */ mode?: DrawingMode; /** * Custom symbols. * * @see {@link Drawing.symbols} */ symbols?: SymbolLookup; /** * Defines when vertices are added during drawing. */ vertexMode?: VertexMode; } /** * Lookup table for symbols. */ type SymbolLookup = { [D in DrawingMode]?: __esri.SymbolProperties | SymbolUnion; }; /** * The type of graphic being drawn. */ type DrawingMode = "rectangle" | "polygon" | "polyline" | "point"; /** * Defines when vertices are added during drawing. * The following values are allowed: * * - `hybrid`: Vertices are added while the pointer is clicked or dragged. * Applies to polygon and polyline draw actions. * - `freehand`: Vertices are added while the pointer is dragged. * Applies to polygon, polyline and segment draw actions. * - `click` : Vertices are added when the pointer is clicked. * Applies to polygon, polyline and segment draw actions. * * This property relates to the property 'mode' used in * different drawings types in the ArcGIS Maps SDK for JavaScript. * See https://developers.arcgis.com/javascript/latest/api-reference/esri-views-draw-PolygonDrawAction.html * for example. */ type VertexMode = "hybrid" | "freehand" | "click"; /** * Reference "mapdraw-api.DrawingFactory" to inject an instance of this factory. */ interface DrawingFactory { /** * Constructs a new {@link Drawing} instance using the given options. */ createDrawing(options: DrawingOptions): Drawing; } export type { Drawing, DrawingFactory, DrawingMembers, DrawingMode, DrawingOptions, SymbolLookup, VertexMode };