Show cluster count 1

259
1
06-02-2022 08:43 PM
AntonioGallo
New Contributor

Hello,
i am using GeoJSONLayer  with featureReduction to show the cluster in the Map. 

I need to show on the map also the cluster that count 1. 
I read  that: "There's no such thing as clusters with a count of one. If a feature does not belong to a cluster, it is rendered by itself according the configuration defined in the layer's renderer."

However i do not understand how to define the configuration in the layer's renderer to show point do not clustered on the map.

I am using version javascript 4.23

Tags (1)
0 Kudos
1 Reply
KristianEkenes
Esri Regular Contributor

Hi @AntonioGallo ,

The configuration API for cluster labels and popups is very similar to the layer labels and popups. To label clusters and individual features, you need to use the following:

layer.featureReduction = {
  type: "cluster",
  labelingInfo: [
   // define label classes here for clusters
  ]
};

layer.labelingInfo = [{
  // define label classes here for individual features
}];

 

This sample application does both, though I admit the label classes are a bit more complex as they handle different styles and label placements at various scale levels: https://developers.arcgis.com/javascript/latest/sample-code/featurereduction-cluster-filter-slider/ 

See the image below: 

KristianEkenes_0-1659554403332.png

The green point indicated by the red arrow is an individual power plant. It is not labeled with a "1", but rather with the information for the plant itself in the layer.lablingInfo property (since it is not a cluster). The other blue symbols are clusters of 4 and 5 power plants respectively. Those labels are defined on the layer.featureReduction.labelingInfo property. Notice the label placement is different. That is because each label comes from a different label class, which is defined based on the average size of power plant in the cluster.

Hopefully that helps.

Kristian

0 Kudos