Marker series
Forty-one capitals, and clusters only where pins collide
A marker says "something is here", so its size never varies. What varies is whether a place is drawn at all: where pins would overlap into a blob, they merge. Two groups qualify at this frame and the other thirty-five capitals stay pins, which is the point. Clustering that hides your data to tidy the picture answers a question nobody asked, and one zoom step is enough to dissolve both.
Capitals 27 EU member states and 14 other European capitals Geometry Natural Earth 1:50m, built-in registry Projection Lambert azimuthal equal-area, centred 10°E 52°N
What was passed
One series, one cluster object
Clustering is an option on the marker series rather than a series of its own, because the data is identical either way and only the drawing changes. Turning it off is one key, and the map redraws from the same array.
{
type: 'marker',
data: capitals, // { name, lon, lat, bloc }
shape: 'pin', // anchored at its point, not its centre
size: 15,
colorBy: 'bloc', // categorical colour and a legend, automatically
stroke: { color: '#141a22', width: 1.3 },
cluster: {
radius: 34, // merge distance in screen pixels
minPoints: 3, // a pair stays two pins
},
}
Why it behaves
Three decisions you can see
Distance, not grid cells. Bucketing points into cells is simpler, but it splits two points a few pixels apart that straddle a boundary while merging two at opposite corners of one cell. The grid here is only a neighbour index and the merge test is real distance, which is why the two groups that form are the two a reader would draw by hand: Vienna with Bratislava and Budapest, and Brussels with Amsterdam and Luxembourg. Reykjavík joins nothing at any zoom.
World space, quantized zoom. Panning never reclusters, so counts do not renumber under the cursor, and a smooth pinch recomputes a handful of times instead of sixty times a second. The merge distance is in screen pixels, so it follows the frame: narrow this window to a phone and two more groups appear, the Baltic capitals and the Balkans, because at that size those pins really would overlap.
Centre of mass, square-root sizing. A cluster drawn on its first member sits off to one side of the group it stands for, and one scaled by count makes a group of nine look three times a group of three when it is three times as many.