UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

50 lines (49 loc) 2.97 kB
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`. * * @example * // get screen point from view's click event * view.on("click", (event) => { * // Search for all features only on included layers at the clicked location * view.hitTest(event, {include: vectorTileLayer}).then((response) => { * // if graphics are returned from vector tile layer, do something with results * if (response.results.length){ * response.results.forEach((result, i) => { * const layerId = result.graphic?.origin?.layerId; * const styleLayer = vectorTileLayer.getStyleLayer(layerId); * // update vector tile layer's style * }); * } * }) * @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/) */ 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"]; }