import type Graphic from "../Graphic.js"; import type Collection from "../core/Collection.js"; import type Layer from "./Layer.js"; import type { MultiOriginJSONSupportMixin } from "../core/MultiOriginJSONSupport.js"; import type { BlendLayer, BlendLayerProperties } from "./mixins/BlendLayer.js"; import type { OperationalLayer, OperationalLayerProperties } from "./mixins/OperationalLayer.js"; import type { PortalLayer, PortalLayerProperties } from "./mixins/PortalLayer.js"; import type { ScaleRangeLayer, ScaleRangeLayerProperties } from "./mixins/ScaleRangeLayer.js"; import type { GraphicProperties } from "../Graphic.js"; import type { ReadonlyArrayOrCollection } from "../core/Collection.js"; import type { LayerProperties } from "./Layer.js"; /** @since 5.2 */ export interface SketchLayerProperties extends LayerProperties, PortalLayerProperties, OperationalLayerProperties, ScaleRangeLayerProperties, BlendLayerProperties { /** A collection of graphics owned by this SketchLayer. Graphics are saved in type-specific feature collections. */ graphics?: ReadonlyArrayOrCollection; /** * Indicates how the layer should display in the [LayerList](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/) widget. * The possible values are listed below. * * Value | Description * ------|------------ * show | The layer is visible in the table of contents. * hide | The layer is hidden in the table of contents. * * @default "show" */ listMode?: "show" | "hide"; /** * The title of the layer used to identify it in places such as the [LayerList](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/) * and [Popup](https://developers.arcgis.com/javascript/latest/references/core/widgets/Popup/) widgets. * * @default "Sketch" */ title?: string | null; } /** * The SketchLayer lets you display and modify sketches (features sketched on a web map) from the * [Map Viewer](https://www.arcgis.com/apps/mapviewer/index.html). A new SketchLayer can also be used with the * [Sketch component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-sketch/) * or the [SketchViewModel](https://developers.arcgis.com/javascript/latest/references/core/widgets/Sketch/SketchViewModel/) in a 2D [MapView](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/). * * Sketches belong to the [graphics](https://developers.arcgis.com/javascript/latest/references/core/layers/SketchLayer/#graphics) collection. Each graphic can have its own * popup template, geometry, and symbol. * * Sketches are part of web maps, and are typically created with the Map Viewer. For additional information, please refer to the * ArcGIS Online documentation on how to * [Create sketch layers](https://doc.arcgis.com/en/arcgis-online/create-maps/create-sketch-layers-mv.htm). * Within the [web map specification](https://developers.arcgis.com/web-map-specification/), sketches are a special type of * [FeatureCollections](https://developers.arcgis.com/web-map-specification/objects/featureCollection/). * Graphics are saved in type-specific feature collections. Their global ordering across geometry types is not preserved on save and load. * * Existing sketches in web maps and Map Notes or Markup portal items load as [MapNotesLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/MapNotesLayer/) by default. * To load them as SketchLayer instances, set the `sketch-layer-enabled` flag in the global `esriConfig` before loading ArcGIS modules: * ```html * * ``` * * Sketches created with Map Viewer Classic can be displayed, but the sketches cannot be modified or accessed with this class. * To find if the sketches in the SketchLayer can be edited, check the * [capabilities.operations.supportsMapNotesEditing](https://developers.arcgis.com/javascript/latest/references/core/layers/SketchLayer/#capabilities) property value. * * > [!WARNING] * > * > **Known Limitations** * > * > Currently, SketchLayer is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). * > SketchLayer does not support the [Legend](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-legend/). * > Changes to the visibility, scale range, and opacity properties are not persisted. * > Sketches created with Map Viewer Classic do not support editing. * * With the flag enabled, the following snippet loads an existing web map that contains a Sketch layer. * ```html * * * * ``` * * With the flag enabled, this snippet loads a Sketch layer from an existing portal item. * * ```ts * const promise = Layer.fromPortalItem({ * portalItem: { * id: "2e2f6840647d4cb9a384532652e5100f" * } * }); * promise.then((layer) => { * console.log(layer.type); // "sketch" * map.add(layer); * }); * ``` * * @since 5.2 * @beta * @see [Map](https://developers.arcgis.com/javascript/latest/references/core/Map/) * @see [WebMap](https://developers.arcgis.com/javascript/latest/references/core/WebMap/) * @see [SketchViewModel](https://developers.arcgis.com/javascript/latest/references/core/widgets/Sketch/SketchViewModel/) */ export default class SketchLayer extends SketchLayerSuperclass { constructor(properties?: SketchLayerProperties); /** Describes the layer's supported capabilities. */ get capabilities(): SketchLayerCapabilities; /** A collection of graphics owned by this SketchLayer. Graphics are saved in type-specific feature collections. */ get graphics(): Collection; set graphics(value: ReadonlyArrayOrCollection); /** * Indicates how the layer should display in the [LayerList](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/) widget. * The possible values are listed below. * * Value | Description * ------|------------ * show | The layer is visible in the table of contents. * hide | The layer is hidden in the table of contents. * * @default "show" */ accessor listMode: "show" | "hide"; /** * The title of the layer used to identify it in places such as the [LayerList](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/) * and [Popup](https://developers.arcgis.com/javascript/latest/references/core/widgets/Popup/) widgets. * * @default "Sketch" */ accessor title: string | null | undefined; /** The layer type provides a convenient way to check the type of the layer without the need to import specific layer modules. */ get type(): "sketch"; /** * Adds a graphic to this SketchLayer. * * @param graphic - The graphic to add. * @returns This layer. */ add(graphic: Graphic): this; /** * Removes a graphic from this SketchLayer. * * @param graphic - The graphic to remove. */ remove(graphic: Graphic): void; } declare const SketchLayerSuperclass: typeof Layer & typeof MultiOriginJSONSupportMixin & typeof PortalLayer & typeof OperationalLayer & typeof ScaleRangeLayer & typeof BlendLayer /** @since 5.2 */ export interface SketchLayerCapabilities { /** Describes operations that can be performed on map notes in the layer. */ operations: SketchLayerCapabilitiesOperations; } /** @since 5.2 */ export interface SketchLayerCapabilitiesOperations { /** * Indicates if map notes in the layer can be edited. Map notes * created with the Map Viewer will have a value of `true`. Map notes created with the Map Viewer Classic will * have a value of `false`. */ supportsMapNotesEditing: boolean; }