Skip to main content
Glama

highlight

Highlight specific features on CesiumJS 3D globe layers to emphasize spatial data for analysis or visualization.

Instructions

高亮指定图层的要素

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
layerIdYes图层ID
featureIndexNo要素索引(不传则高亮全部)
colorNo高亮颜色(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
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gaopengbin/cesium-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server