How to cluster features by equal attributes?

322
1
Jump to solution
06-08-2020 07:25 AM
ChristianBischof
Esri Contributor

Hey guys I'm using JS API 4.15 and have some issues with the clustering / featureReduction.

I am clustering a feature layer with an attribute called status. Right now every feature of the feature layer is clustered if it's inside the featureRadius. What I want to achieve is that if two features of the same layer are next to each other, but don't have the same status, that they don't get clustered together.

Example:

5 features are within the clusterRadius, but only 3 of them also have the same status -> only those 3 should be clustered together and the other two ones stay as they are (if those remaining two features would have the same status obviously they'd get clustered together as well).

https://developers.arcgis.com/javascript/latest/sample-code/featurereduction-cluster-filter/live/index.html

In this sample we can see the same behaviour for example in the South the features are clustered together as "Hindu" although if we zoom in further, we can see that there  were "Christian" features in the "Hindu" cluster. In my example this would mean that only the same religion (e.g."Hindu" features) gets clustered together.

I am also using a uniqueValueRenderer for my feature layer as they do in the sample above.

If anybody could provide a suggestion or sample code I'd be grateful!

Thanks in advance and happy coding

0 Kudos
1 Solution

Accepted Solutions
KristianEkenes
Esri Regular Contributor

Hi Christian,

There currently isn't a way to do this other than creating separate layers with filters based on the status field and clustering each of those. I'll take this back to the team and we'll discuss it.

Kristian

View solution in original post

1 Reply
KristianEkenes
Esri Regular Contributor

Hi Christian,

There currently isn't a way to do this other than creating separate layers with filters based on the status field and clustering each of those. I'll take this back to the team and we'll discuss it.

Kristian