0

I use supercluster to display clusters on mabox with react-map-gl. If I click on a cluster, it doesn't zoom in as expected, but the above error is thrown. Does anyone know why or has the same problem solved?

Uncaught TypeError: Cannot read properties of undefined (reading 'length')

       if (isCluster) {
            return (
              <Marker
                key={`cluster-${cluster.id}`}
                longitude={longitude}
                latitude={latitude}
              >
                <div
                  className="cluster-marker"
                  style={{
                    width: `${10 + (point_count / articels.length) * 20}px`,
                    height: `${
                      10 + (point_count / articels.length) * 20
                    }px`,
                  }}
                  onClick={() => {
                    //cluster.id = 16
                    const zoom = Math.min(
                      supercluster.getClusterExpansionZoom(cluster.id),
                      20
                    );
                    mapRef.current.flyTo({
                      center: [longitude, latitude],
                      zoom,
                      speed: 5,
                    });
                  }}
                >
                  {point_count}
                </div>
              </Marker>
            );
          }
Captai-N
  • 1,124
  • 3
  • 15
  • 26

0 Answers0