Hello,
When I click on the map, I get a cluster feature with attributes (clusterId, clster_count). But how can I get source features included in the cluster?
Now I see one way: create a circle with center = cluster point and radius = cluster radius, then query features from the layer (query.geomerty = circle).
Is this a 3.x or 4.x question?
This Beta class does not offer any way to determine the graphics in the cluster so using the cluster graphic and the cluster radius (like you mentioned) would be your best route currently.
I have tried.
It is the wrong way because areas of two (and more) clusters intersected... And I get the same feature in both clusters
I am also looking for a similar solution to this problem. Have you been able to find a proper solution?
I am following this as well. I thought the Sandbox here would help, but I'm still quite stuck.
For example, I'm passing the cluster graphic this is clicked to the following function, which is really close to what the Sandbox provides. My screen does register a change, but it never is pulling back ONLY the features in the cluster.
The popup label does accurately count how many features are clustered, but is there any updated guidance on accessing the underlying features?
async displayClusterExtent(graphic) {
const query = this.layerView.createQuery();
query.aggregateIds = [graphic.getObjectId()];
const { extent } = await this.layerView.queryExtent(query);
this.view.goTo(extent);
}
And then just to follow up, I also snagged this piece of code from the sample to find the exact features.
async countFeatures(graphic) {
const query = this.layerView.createQuery();
query.aggregateIds = [ graphic.getObjectId() ];
// returns the features represented by the cluster with an ObjectID of 1
const { features } = await this.layerView.queryFeatures(query);
console.log(graphic.getObjectId())
console.log(features.length)
}
I think clicked on these two clusters in my map.
And I came to this result. The first shows the ObjectId and the second shows the length of the returned attributes. I must be doing something wrong, but they are both returning the exact same features, and neither represents the actual features of the clicked graphic.
Any ideas? 😥
Check the new feature in 4.18!
https://community.esri.com/t5/arcgis-api-for-javascript/get-underlying-object-id-graphics-in-cluster...
Yes it's working great now! I wasn't explicitly calling out the version 4.18 when loading modules, and so what was actually happening was my query was returning all points.
For anyone who might be seeing this after me, a good way to check is to inspect your symbol. If it doesn't have the "isAggregate" property on it, you aren't using 4.18.