nadiamoa
nadiamoa

Reputation: 1

ESRI JS : To spiderfy a cluster

I am using ESRI JS API (4.23), and I can't find a way to spiderfy my clusters ( similar to what we can do with a Cluster using leaflet), has anyone already tried to do that ?

Here is an exaplme of what I am looking to create : SpiderfiedCluster

Upvotes: 0

Views: 81

Answers (1)

odoenet
odoenet

Reputation: 249

That is not a supported capability in the SDK. You might be able to do something similar querying the aggregate features and displaying them. This sample does something similar with convex hull. https://codepen.io/odoe/pen/RwBPKyw

view.on(
    "pointer-move",
    debounce(async (e) => {
        if (!layerView) return;
        try {
            const { results } = await view.hitTest(e);
            if (results.length && results[0].graphic.isAggregate) {
                const query = layerView.createAggregateQuery();
                query.aggregateIds = [results[0].graphic.getObjectId()];
                await whenOnce(() => !layerView.updating);
                const fSet = await layerView.queryFeatures(query);
                const geoms = union(fSet.features.map((x) => x.geometry));
                const geom = convexHull(geoms, true);
                view.graphics.removeAll();
                view.graphics.add({
                    geometry: geom,
                    symbol: fill
                });
            }
        } catch (error) {}
    })
);

Upvotes: 0

Related Questions