When a user clicks a map, I use scene.drillPick method to get a list of objects with appropriate entities in id field. This works great for simple points and polygons.
But now I am trying to enable clustering for my points, and I'd like to get a list of contained entities when a user clicks a cluster. Is it possible?
drillPick returns an object, but it's id field is set to "undefined". Two other fields - collection and primitive - contains some data, but I can't find a way to get clustered entities via these fields.
Google didn't help either.
Thanks in advance!
I'd also like to second this question. Some of our data has multiple entities at the same position, and clustering is essential to identify these positions/entities, in addition to prettifying the display. I've tried numerous methods: exploring if it requires adding a separate datasource for the clustered billboards, delving into the 'collection' and 'primitive' objects of each billboard that's clicked (as TDenis noted above), and worst case was going to try to create a rectangle for each clicked position to determine if there are individual entities within the rectangle.
One thing I noticed was that if you click an "un-clustered" entity, it's 'collection' property seems to reference the entityCluster's _clusterPointCollection AND _pointCollection. Whereas if you click the billboard for a clustered entity, it's collection property references the entityCluster's _clusterBillboardCollection and _billboardCollection -- but the _billboardCollection shows as 'undefined'.
Is some billboard collection not initialized that needs to be?
Main question as TDenis noted is why the billboard selection has an undefined id?
Found a couple options here.
First, you can set cluster.billboard.id in a "clusterEvent" listener. That object can be found in picked object's id field.
Second, looks like picked object's primitive field contains a cluster.billboard object specified in a "clusterEvent" listener. So in that listener we can just add custom fields to billboard and put some data there.
Looks like you found a bug! The object returned from scene.pick should have an id field that is an array of the clustered entities. There was an issue opened for this recently:
I’ve linked to this thread so we can notify you when we get a chance to fix it. However, if you’re interested, you’re welcome to give it a try! I’ve be happen to provide guidance on making a contribution.
This bug has been fixed and will be included in the 1.35 release coming out on July 5th.
Hope this helps you move forward with your work!