1

Is there any way of clustering points by field from properties object? I am using react-map-gl library.

https://visgl.github.io/react-map-gl/examples/clusters

Example feature object:

{
      type: "Feature",
      geometry: {
        type: "Point",
        coordinates: cords,
      },
      properties: {
        ...item,
        layer_id: item.id,
        name: item.name,
        FIELD_TO_CLUSTER_BY: example
      },
};
<Source
  id="markers"
  type="geojson"
  data={features}
  cluster={true}
  clusterMaxZoom={14}
  clusterRadius={50}
  clusterProperties={{
  }}
  >
   <Layer {...clusterLayer} />
   <Layer {...unclusteredPointLayer} />
  </Source>

In radius of 50 i would like to cluster all markers that FIELD_TO_CLUSTER_BY equals to 'something'

I was thinking about grouping data by FIELD_TO_CLUSTER_BY and create separate source and layer for each of them.

1 Answers1

0

So the solution that i found (don't know if it is best) is to group all points by FIELD_TO_CLUSTER_BY property and to display them i needed to loop through grouped arrays and for each of them i created new and