Skip to main content

Labels

A label puts text on the features matching a class — typically the value of a column. A label maps to a MapServer LABEL block. A class can hold multiple label entries, each with its own text, styling and optional expression filter.

The label text usually references a column, e.g. [name], and can combine several columns and literals. The layer properties label_column, label_min_scale and label_max_scale set layer-wide labelling defaults — see Layers.

Get labels

All labels of a class
GET https://api.centia.io/api/v4/layers/rockhall.venues.the_geom/classes/1/labels HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123
A specific label
GET https://api.centia.io/api/v4/layers/rockhall.venues.the_geom/classes/1/labels/1 HTTP/1.1
Accept: application/json; charset=utf-8
Authorization: Bearer abc123

Add a label

The server assigns the label id — a request that includes an id is rejected with 400.

Label with a halo and background
POST https://api.centia.io/api/v4/layers/rockhall.venues.the_geom/classes/1/labels HTTP/1.1
Content-Type: application/json
Authorization: Bearer abc123

{
"on": true,
"text": "[name]",
"font": "arial",
"fontweight": "bold",
"size": "12",
"color": "#000000",
"outlinecolor": "#FFFFFF",
"backgroundcolor": "#FFFFCC",
"position": "auto",
"buffer": "4"
}
Label only large venues, repeated along lines
POST https://api.centia.io/api/v4/layers/rockhall.tours.the_geom/classes/1/labels HTTP/1.1
Content-Type: application/json
Authorization: Bearer abc123

{
"on": true,
"text": "[band]",
"expression": "([attendance] > 10000)",
"angle": "follow",
"repeatdistance": "200"
}

Update a label

PATCH merges the keys you send into the label:

Turn a label off
PATCH https://api.centia.io/api/v4/layers/rockhall.venues.the_geom/classes/1/labels/1 HTTP/1.1
Content-Type: application/json
Authorization: Bearer abc123

{
"on": false
}

Delete a label

DELETE https://api.centia.io/api/v4/layers/rockhall.venues.the_geom/classes/1/labels/1 HTTP/1.1
Authorization: Bearer abc123

Label properties

Numeric values are stored as strings; an empty string means unset.

PropertyDescription
idFixed, server-assigned id.
nameDisplay name (UI only).
sortidRender order. Defaults to highest existing + 10.
onBoolean. Whether the label is enabled.
textLabel text expression, e.g. [name].
expressionWhen set, this label is only rendered for features matching the expression.
fontFont family, e.g. arial or courier (available families depend on server configuration).
fontweightnormal, bold, italic or bolditalic.
sizeFont size in pixels. Defaults to 11. Accepts [column].
colorText color. Defaults to black.
outlinecolorHalo color around the text for legibility. Defaults to white.
positionPlacement relative to the anchor point: auto or a combination of upper/center/lower and left/center/right (ul, uc, ur, cl, cc, cr, ll, lc, lr).
bufferMinimum distance in pixels kept clear around the label.
repeatdistanceDistance in pixels at which the label repeats along a line feature.
angleRotation in degrees, auto, auto2 or follow for orientation along the feature, or [column].
backgroundcolorFill color of a rectangle behind the text. Empty disables the background.
backgroundpaddingPadding in pixels around the text when backgroundcolor is set. Defaults to 1.
offsetx / offsetyPixel offset applied to the label position.
forceBoolean. Always draw the label even if it overlaps others.
minscaledenom / maxscaledenomScale range in which the label is drawn.
maxsizeMaximum font size in pixels when scaling text. Defaults to 256.
minfeaturesizeMinimum feature size in pixels required to be labelled, or auto.
Leader lines

When labels must be moved away from crowded features, enable a leader line on the class with leader, leader_color, leader_gridstep and leader_maxdistance — the label is then connected to its feature with a line.