要移除Cesium中由CustomDataSource创建的实体,可以使用CustomDataSource的方法'remove(entity)'。以下是一个示例代码:

// 创建CustomDataSource对象
var dataSource = new Cesium.CustomDataSource();

// 创建实体
var entity = dataSource.entities.add({
    // 实体的属性设置
});

// 添加CustomDataSource到Viewer中
viewer.dataSources.add(dataSource);

// 移除实体
dataSource.entities.remove(entity);

在上面的代码中,首先创建了一个CustomDataSource对象,然后使用'add()'方法添加实体。接下来,将CustomDataSource对象添加到Viewer中的dataSources中。最后,使用'remove()'方法从CustomDataSource中移除实体。

请注意,移除实体后,它将不再在Cesium中显示。但是,如果您重新加载场景或重新加载数据源,实体可能会再次显示。

Cesium中如何移除CustomDataSource创建的实体

原文地址: https://www.cveoy.top/t/topic/pTIy 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录