highlight
Highlight specific features on CesiumJS 3D globe layers to emphasize spatial data for analysis or visualization.
Instructions
高亮指定图层的要素
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| layerId | Yes | 图层ID | |
| featureIndex | No | 要素索引(不传则高亮全部) | |
| color | No | 高亮颜色(CSS 格式) | #FFFF00 |
Implementation Reference
- The `highlight` function implements the logic to highlight entities in a Cesium viewer. It takes the viewer, layer manager, and highlighting parameters. It iterates over entities in a layer and applies a highlight color to them based on their type (polygon, polyline, or point).
export function highlight( viewer: Cesium.Viewer, layerManager: LayerManager, params: HighlightParams, ): void { const { layerId, featureIndex, color = '#FFFF00' } = params const refs = layerManager.getCesiumRefs(layerId) if (!refs?.dataSource) return const entities = refs.dataSource.entities.values const highlightColor = parseColor(color).withAlpha(0.8) if (featureIndex != null && featureIndex < entities.length) { const entity = entities[featureIndex]! applyHighlight(entity, highlightColor) } else { for (const entity of entities) { applyHighlight(entity, highlightColor) } } } - The `HighlightParams` interface defines the input parameters for the highlight tool: `layerId` (string), `featureIndex` (optional number), and `color` (optional ColorInput).
export interface HighlightParams { layerId: string featureIndex?: number color?: ColorInput }