I have a layer of features, and I want to cluster them. I have the cluster set up and originally had a renderer using CIMSymbol to display the name of the feature, along with an icon.
However when I cluster, it shows the number and also the name below the cluster. I would like to only show the feature value when the cluster size is 1.
I tried some where clauses in the labelingInfo array, but that didn't render anything:
const workerClusterConfig = {
type: "cluster",
clusterRadius: "100px",
// {cluster_count} is an aggregate field containing
// the number of features comprised by the cluster
popupTemplate: {
title: "Cluster summary",
content: "This cluster represents {cluster_count} workers.",
fieldInfos: [{
fieldName: "cluster_count",
format: {
places: 0,
digitSeparator: true
}
}]
},
clusterMinSize: "50px",
clusterMaxSize: "50px",
labelingInfo: [{
labelExpressionInfo: {
expression: "$feature.cluster_count"
},
labelPlacement: "center-center",
deconflictionStrategy: "none",
where: `$feature.cluster_count > 1`
},{
labelExpressionInfo: {
expression: "$feature.name"
},
labelPlacement: "below-center",
deconflictionStrategy: "none",
where: `$feature.cluster_count < 2`
},]
};
I am assuming that cluster_count is a number, and that the layer renderer cannot access it. Do I need to move my entire layer renderer down into the cluster render? Do I need a completely different renderer?
Hi,
Do you mind verifying if I have your set up correctly summarized here?
1. You have a layer, rendered with a CIMSymbol in a SimpleRenderer. This symbol contains a TextSymbolLayer to display the name of the feature (I'm guessing by using a primitive override).
2. When you enable featureReduction on the layer, the same symbol is used for the clusters, including the text displaying the feature name. A LabelClass is also generated for the cluster configuration which returns the cluster count in the center of the symbol.
3. Individual features display as expected...using the CIM Symbol with the text symbol layer indicating the feature name.
4. Cluster display is unexpected...you see a name displayed in the cluster symbol and the cluster count. You only want to see cluster count in this scenario.
If this is accurate, then you need to move the feature labels outside of the CIM Symbol and move them to a LabelClass on the layers labelingInfo. This should render the feature labels for individual features only. Cluster labels (cluster count) will only display for clusters of a size 2 or greater.