CustomDataSource

new Cesium.CustomDataSource(name)

A DataSource implementation which can be used to manually manage a group of entities.
Name Type Description
name String optional A human-readable name for this instance.
Example:
const dataSource = new Cesium.CustomDataSource('myData');

const entity = dataSource.entities.add({
   position : Cesium.Cartesian3.fromDegrees(1, 2, 0),
   billboard : {
       image : 'image.png'
   }
});

viewer.dataSources.add(dataSource);

Members

avoidSelfOverlap : Boolean

Billboard或者Label对象重叠检测,开启此项会动态计算、优先显示更靠近视角的billboard或者label,被遮挡的对象不予显示。
Gets an event that will be raised when the underlying data changes.
Gets or sets the clock for this instance.
Gets or sets the clustering options for this data source. This object can be shared between multiple data sources.
Gets the collection of Entity instances.
Gets an event that will be raised if an error is encountered during processing.
重叠检测参数,Billboard或者Label类型对象包围盒的外延像素大小
Gets or sets whether the data source is currently loading data.
Gets an event that will be raised when the data source either starts or stops loading.
Gets or sets a human-readable name for this instance.
Gets whether or not this data source should be displayed.

Methods

getVisibleAtViewport(index)

查询视口是否显示
Name Type Description
index Number 视口索引号,最大值为8,索引号从下到上,左右往返排序

setVisibleAtViewport(index, visible)

数据显示视口设置
Name Type Description
index Number 视口索引号,最大值为8,索引号从下到上,左右往返排序
visible Boolean 是否显示,默认值为true

setVisibleAtViewportOnly(index, visible)

多视口显示设置,可设置该数据仅在指定的视口索引显示或隐藏,index可以为具体值也可为数组,当index为undefined时,该数据在所有窗口显示或隐藏
Name Type Description
index Number | Array 视口的索引值
visible Boolean 显示/隐藏,默认为ture
Example:
obj.setVisibleAtViewportOnly([0,2,4], false);//设置对象仅在0,2,4视口隐藏,其他窗口显示
obj.setVisibleAtViewportOnly([0,1,2,6], true);//设置对象仅在0,1,2,6视口显示,其他窗口隐藏
obj.setVisibleAtViewportOnly(undefined, true);//设置对象仅在所有视口都显示

update(time)Boolean

Updates the data source to the provided time. This function is optional and is not required to be implemented. It is provided for data sources which retrieve data based on the current animation time or scene state. If implemented, update will be called by DataSourceDisplay once a frame.
Name Type Description
time JulianDate The simulation time.
Returns:
True if this data source is ready to be displayed at the provided time, false otherwise.
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.