Skip to main content
Glama

setLayerVisibility

Control layer display in 3D globe visualizations by toggling visibility for specific layers using their unique identifiers.

Instructions

设置图层可见性

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes图层ID
visibleYes是否可见

Implementation Reference

  • The actual handler logic that modifies the Cesium layers' visibility.
    setLayerVisibility(id: string, visible: boolean): void {
      const layer = this._layers.find(l => l.id === id)
      if (!layer) return
      layer.visible = visible
      const refs = this._cesiumRefs.get(id)
      if (!refs) return
      if (refs.dataSource) refs.dataSource.show = visible
      if (refs.entity) refs.entity.show = visible
      if (refs.labelEntities) {
        for (const e of refs.labelEntities) e.show = visible
      }
      if (refs.tileset) refs.tileset.show = visible
      if (refs.imageryLayer) refs.imageryLayer.show = visible
      if (refs.movingEntity) refs.movingEntity.show = visible
      if (refs.trailEntity) refs.trailEntity.show = visible
    }
  • MCP tool registration for 'setLayerVisibility'.
    _registerTool(
      'setLayerVisibility',
      '设置图层可见性',
      {
        id: z.string().describe('图层ID'),
        visible: z.boolean().describe('是否可见'),
      },
      async (params) => {
        const result = await sendToBrowser('setLayerVisibility', params)
        return { content: [{ type: 'text' as const, text: JSON.stringify(result ?? { success: true }) }] }
      },
    )
  • Bridge method that forwards the call to the layer manager.
    setLayerVisibility(id: string, visible: boolean): void {
      this._layerManager.setLayerVisibility(id, visible)
    }

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