import type GraphicOrigin from "./GraphicOrigin.js"; import type KnowledgeGraphLayer from "../layers/KnowledgeGraphLayer.js"; import type KnowledgeGraphSublayer from "../layers/knowledgeGraph/KnowledgeGraphSublayer.js"; /** * Provides information about the [KnowledgeGraphLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/KnowledgeGraphLayer/) from which a graphic originates. * The [layer](https://developers.arcgis.com/javascript/latest/references/core/graphic/KnowledgeGraphGraphicOrigin/#layer) property references the KnowledgeGraphLayer, and the * [sublayer](https://developers.arcgis.com/javascript/latest/references/core/graphic/KnowledgeGraphGraphicOrigin/#sublayer) property references the [KnowledgeGraphSublayer](https://developers.arcgis.com/javascript/latest/references/core/layers/knowledgeGraph/KnowledgeGraphSublayer/) that contains the graphic. * The [origin](https://developers.arcgis.com/javascript/latest/references/core/Graphic/#origin) information may be available when a graphic is returned from methods such as * [hitTest()](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/#hitTest) or [queryFeatures()](https://developers.arcgis.com/javascript/latest/references/core/layers/knowledgeGraph/KnowledgeGraphSublayer/#queryFeatures). * * Before accessing the layer properties, use [isKnowledgeGraphGraphicOrigin](https://developers.arcgis.com/javascript/latest/references/core/graphic/isKnowledgeGraphGraphicOrigin/) to check * whether the graphic's origin is a KnowledgeGraphGraphicOrigin. * * If you only need the title of the originating sublayer, use [getGraphicOriginTitle](https://developers.arcgis.com/javascript/latest/references/core/graphic/getGraphicOriginTitle/). * To get the popup template applicable to the graphic, call [Graphic.getEffectivePopupTemplate()](https://developers.arcgis.com/javascript/latest/references/core/Graphic/#getEffectivePopupTemplate) on the graphic * instead of accessing the sublayer's template directly. * * @since 5.0 * @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 KnowledgeGraphGraphicOrigin extends GraphicOrigin { constructor(layer: KnowledgeGraphLayer, sublayer: KnowledgeGraphSublayer); /** A layer from which a graphic originates. */ readonly layer: KnowledgeGraphLayer; /** The [KnowledgeGraphSublayer](https://developers.arcgis.com/javascript/latest/references/core/layers/knowledgeGraph/KnowledgeGraphSublayer/) from which a graphic originates. */ readonly sublayer: KnowledgeGraphSublayer; /** * Indicates the type of layer the graphic originated from. * * @default "knowledge-graph" */ readonly type: KnowledgeGraphLayer["type"]; }