Select to view content in your preferred language

How to enable clustering in graphics layer or feature layer

430
0
09-27-2023 07:26 PM
EHQAdmin
Emerging Contributor

Hello,

I'm trying to implement clustering with a graphics layer in our application. We are adding multiple symbols with coordinates to the graphics layer, and it appears that enabling clustering directly on the graphics layer is not possible based on the documentation. I am including a few lines of code to provide a better understanding.

I need assistance with one of the following approaches:

1. How can I add graphics to a feature layer, especially when the graphics' names are coming from an API?

2. How can I enable clustering in the graphics layer?

 const loadPins = () => {
    for(let i=0;i<markers.length; i++){
      const marker = markers[i];
      const graphic = new Graphic({
        symbol: new WebStyleSymbol({
          name: marker.pinIcon,
          styleName: "Esri2DPointSymbolsStyle",
        }),
        geometry: new Point({
          longitude: marker.lng,
          latitude: marker.lat
        }),
        attributes: {
          ...marker
        }
      })
      graphicsLayer.add(graphic); // How to add to feature layer?
    }
    map.add(graphicsLayer)
  }

This feature is critical for our product, and I would greatly appreciate your help in finding a solution. Thank you.

0 Kudos
0 Replies