Select to view content in your preferred language

how to show the label of the count of the clustered points

1455
4
02-07-2020 08:31 AM
聖智王
Emerging Contributor

Hi everyone!

Does anyone know how to add  the label of the count of the clustered points using the class FeatureLayer 's featureReduction atrrtibute?

The result may like the following picture which each circle showing a label with the count of clusterd points.

The class FeatureLayer clustering sample link is  ArcGIS API for JavaScript Sandbox .

0 Kudos
4 Replies
Noah-Sager
Esri Regular Contributor

Great question. While featureReduction (clustering) has recently been released in beta, at a future release we will be adding support for labeling the total count of features represented by the cluster, and/or any other aggregate information known by the cluster.

API Reference: FeatureReductionCluster | ArcGIS API for JavaScript 4.14 

0 Kudos
聖智王
Emerging Contributor

thank you!

0 Kudos
AlexisCuicui
Emerging Contributor

Here's one way to adapt the Cluster Layer while feature Reduction is set. Extract the JS file in the attached zip.

Two ways to call it :

In a Widget :

 define([
    "./ClusterManagerExtented"
  ], function(ClusterManagerExtented
  ) {

    postCreate : function(){
      ClusterManagerExtented._initExtension();
    },

 

In an hosted application :

 require([
    "./ClusterManagerExtented"
  ], function(ClusterManagerExtented
  ) {
    ClusterManagerExtented._initExtension();

 

After the call you will be able to add new options to the setFeature Reduction :

- "count" : is a boolean. Set to True to enable cluster count label. Default is false.

-"symbol": is an JSON Object. Set a "text symbol" as JSON.

Example below :

    layer.setFeatureReduction: {
        type: "cluster"
        clusterRadius:"80",
        count:true,
        symbol:{ "color": [0, 0, 0, 127],
                "type": "esriTS",
                "verticalAlignment": "middle",
                "horizontalAlignment": "center",
                "angle": 0,
                "xoffset": 0,
                "yoffset": 0,
                "text": z.attributes.cluster_count,
                "rotated": false, "kerning": true, "font": { 
                   "size": 9,
                   "style": "normal",
                   "weight": "bold",
                   "family": "Arial"}
              }

 

0 Kudos
AlexisCuicui
Emerging Contributor

Hi,

I'm sorry to dig-up this thread, I need more precisions on wich API betwen the 3.X and the 4.X will have the cluster attributes implemented. It seems to be in beta on the API 4, but not in the API 3. Will the cluster attributes/calculations for features reductions be implemented in the API 3 ?

Thank you.

A.C

0 Kudos