setLayerVisibility
Control layer display in 3D globe visualizations by toggling visibility for specific layers using their unique identifiers.
Instructions
设置图层可见性
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | 图层ID | |
| visible | Yes | 是否可见 |
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 } - packages/cesium-mcp-runtime/src/index.ts:560-571 (registration)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) }