Where to put a polygon's label
Centroid, point on surface, or a point you already store. How MapSocket generates label points for polygon layers, and when to pick each one.
Labelling polygons straight from their geometry is harder than it looks. A renderer that places one label per polygon per tile will repeat a big parcel’s name at every tile edge, and it has no good idea where the middle of a river-shaped district is.
The usual fix is a separate point layer that holds one label point per feature. MapSocket can now build that layer
for you. Turn on label points for a polygon layer and its tiles get a companion layer, {layer}_labels, with one
point per feature and the same properties. It updates live alongside the polygons.
Three ways to place the point
| Method | PostGIS | Good for | Watch out for |
|---|---|---|---|
| Point on surface (default) | ST_PointOnSurface | Any shape | Not always visually centred |
| Centroid | ST_Centroid | Compact, convex shapes | Can fall outside the polygon |
| Your own column | a POINT column | Hand-placed labels | You keep it up to date |
Point on surface is guaranteed to lie inside the polygon. For a convex shape it lands close to the middle; for a C-shaped lot or a multi-part feature it’s still somewhere you can see, which is why it’s the default.
Centroid is the centre of mass. On a square or a circle it’s exactly where you’d put a label by hand. On a horseshoe it sits in the gap, which puts the label on the neighbouring feature. Use it when you know your shapes are compact and you want the most balanced placement.
Your own column is for when someone has already decided where labels go. Many cadastral and planning datasets carry a hand-placed label point; pick that column and MapSocket uses it as-is.
Setting it up
In the dashboard, open the layer and choose a method under Label points. The option only appears for polygon layers, and if you choose a column we check it’s a readable point geometry column before saving.
On the map side, style the label layer like any other symbol layer:
map.addLayer({
id: "parcel-names",
type: "symbol",
source: "parcels",
"source-layer": "parcels_labels",
layout: { "text-field": ["get", "name"], "text-size": 12 },
});
Because there’s exactly one point per feature in each tile that contains it, labels stop stuttering at tile seams.
We’ve written the same option for tilefeed itself, as a label_point_method setting, so it will be there if you
run tilefeed yourself once it’s merged upstream.