产品: iclient3d for webgl 操作系统:win10 x64
聚合设置:
const pixelRange = 10;
const minimumClusterSize = 2;
//启用集群
clusteringlayer.clustering.enabled = true;
//设置扩展屏幕空间边界框的像素范围。
clusteringlayer.clustering.pixelRange = pixelRange;
//可以群集的最小屏幕空间对象
clusteringlayer.clustering.minimumClusterSize = minimumClusterSize;
//将进行实体的广告牌聚类
clusteringlayer.clustering.clusterBillboards = true;
clusteringlayer.clustering.clusterLabels = true
clusteringlayer.clustering.clusterEvent.addEventListener(
function(clusteredEntities, cluster) {
const entity = clusteredEntities[0];
cluster.label.show = true;
cluster.label.text = entity._label._text._value;
cluster.label.font = '15px Microsoft Yahei';
cluster.label.pixelOffset = new Cesium.Cartesian2(0, -50)
cluster.billboard.show = true;
cluster.billboard.scale = 2.0
cluster.billboard.alignedAxis = Cesium.Cartesian3.ZERO
cluster.billboard.width = 20
cluster.billboard.height = 20
cluster.billboard.id = cluster.label.id;
cluster.billboard.verticalOrigin =
Cesium.VerticalOrigin.BOTTOM;
cluster.billboard.disableDepthTestDistance =
Number.POSITIVE_INFINITY;
cluster.billboard.image =
entity._billboard._image._value;
}
);
如图上,已经设置了label和billboard聚合,但label文字总会叠在一起,如下图所示:
下图是没聚合的时候