Cluster points - identify

1333
9
05-22-2020 03:46 AM
АлексейШульга
New Contributor II

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).

0 Kudos
9 Replies
RobertScheitlin__GISP
MVP Emeritus

Is this a 3.x or 4.x question?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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.

0 Kudos
АлексейШульга
New Contributor II

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

by Anonymous User
Not applicable

I am also looking for a similar solution to this problem. Have you been able to find a proper solution? 

rogenjh
New Contributor III

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);
}

 

0 Kudos
rogenjh
New Contributor III

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.

rogenjh_0-1608768217189.png

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. 

rogenjh_1-1608768304902.png

Any ideas? 😥

 

0 Kudos
by Anonymous User
Not applicable
rogenjh
New Contributor III

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.

0 Kudos