removeLayer
Remove a specific layer from a 3D globe by its ID to declutter the map display and manage visualization layers.
Instructions
从地图上移除指定图层(按图层ID)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | 要移除的图层ID(可通过 listLayers 获取) |
Implementation Reference
- The implementation of removeLayer, which removes a layer from the Cesium viewer by ID.
removeLayer(id: string): void { const idx = this._layers.findIndex(l => l.id === id) if (idx === -1) return const refs = this._cesiumRefs.get(id) if (refs) { if (refs.dataSource) this._viewer.dataSources.remove(refs.dataSource, true) if (refs.entity) this._viewer.entities.remove(refs.entity) if (refs.labelEntities) { for (const e of refs.labelEntities) this._viewer.entities.remove(e) } if (refs.tileset) this._viewer.scene.primitives.remove(refs.tileset) if (refs.imageryLayer) this._viewer.imageryLayers.remove(refs.imageryLayer)