import type GraphicOrigin from "./GraphicOrigin.js"; import type VectorTileLayer from "../layers/VectorTileLayer.js"; /** * Provides information about the [VectorTileLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/VectorTileLayer/) from which a graphic originates. * Origin information maybe available when a graphic is returned from methods such as [MapView.hitTest()](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/#hitTest) method. * You can access the graphic's origin through the graphic's [Graphic.origin](https://developers.arcgis.com/javascript/latest/references/core/Graphic/#origin) property. * * The origin information contains the style layer's [id](https://maplibre.org/maplibre-style-spec/layers/#id) and layer index * within the [vector tile style](https://doc.arcgis.com/en/arcgis-online/reference/tile-layers.htm#ESRI_SECTION1_8F68399EB47B48FF9EF46719FCC96978). * Spatial information about the actual feature represented in the style layer is returned only * if the style layer is a [symbol layer](https://maplibre.org/maplibre-style-spec/layers/#symbol). Otherwise, the graphic's geometry is `null`. * * Before accessing the layer properties, use [isVectorTileGraphicOrigin](https://developers.arcgis.com/javascript/latest/references/core/graphic/isVectorTileGraphicOrigin/) to check * whether the graphic's origin is a VectorTileGraphicOrigin. * * @since 4.34 * @see [MapView.hitTest()](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/#hitTest) * @see [Map component hitTest()](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-map/#hitTest) * @see [Sample - VectorTileLayer hitTest](https://developers.arcgis.com/javascript/latest/sample-code/layers-vectortilelayer-hittest/) * @example * Access the layer and sublayer of a graphic that originated from a MapImageLayer. * ```js * import { isMapImageGraphicOrigin } from "@arcgis/core/graphic/isMapImageGraphicOrigin.js"; * * const origin = graphic.origin; * * // Check whether the graphic came from a MapImageLayer * if (isMapImageGraphicOrigin(origin)) { * console.log(origin.layer.title); * console.log(origin.sublayer.title); * } * ``` * @example * Access the vector tile style layer associated with a graphic returned by hitTest(). * ```js * import { isVectorTileGraphicOrigin } from "@arcgis/core/graphic/isVectorTileGraphicOrigin.js"; * * viewElement.addEventListener("arcgisViewClick", async (event) => { * // Get hit-test results from the VectorTileLayer at the clicked location * const response = await view.hitTest(event.detail, { include: vectorTileLayer }); * * for (const result of response.results) { * // Only graphic results contain a graphic with origin information * if (result.type !== "graphic") { * continue; * } * * const graphic = result.graphic; * const origin = graphic.origin; * * // Check whether the graphic came from a VectorTileLayer * if (isVectorTileGraphicOrigin(origin)) { * // layerId identifies a style layer within the VectorTileLayer * const styleLayer = origin.layer.getStyleLayer(origin.layerId); * console.log(styleLayer); * } * } * }); * ``` */ export default class VectorTileGraphicOrigin extends GraphicOrigin { constructor(layer: VectorTileLayer, layerId: string, layerIndex: number); /** A layer from which a graphic originates. */ readonly layer: VectorTileLayer; /** * The [unique identifier](https://maplibre.org/maplibre-style-spec/layers/#id) of the style layer in the * [vector tile style](https://maplibre.org/maplibre-style-spec). */ readonly layerId: string; /** The layer index of the style layer in the [vector tile style](https://maplibre.org/maplibre-style-spec). */ readonly layerIndex: number; /** * Indicates the type of layer the graphic originated from. * * @default "vector-tile" */ readonly type: VectorTileLayer["type"]; }