Using the MapServer Label and Style Property Binding
MapServer supports binding some of the label and style properties to layer attributes. In this case the actual values of the attributes are retrieved from the features when the layer is rendered.
The label property binding can be set in the Label Property Editor, the style property binding can be set in the Style Property Editor. Only the labels with blue hyperlinks are allowed to specify the bindings.
You can toggle the binding option by clicking on any of the blue hyperlinks. When the bound mode is enabled a list of the available attributes are enumerated in a combobox and a small icon is displayed near to the corresponding control.
For the OGR data sources further "meta-attributes" are available related to the properties of the attached features native style.
These are:
- OGR:LabelFont - The font of the label
- OGR:LabelSize - The size of the label. Numeric value with units.
- OGR:LabelText - The text of the label.
- OGR:LabelAngle - Rotation angle (in degrees, counterclockwise).
- OGR:LabelFColor - Text foreground colour. Expressed in hexadecimal (#RRGGBB[AA]) .
- OGR:LabelBColor - Text background colour. Expressed in hexadecimal (#RRGGBB[AA]).
- OGR:LabelPlacement - Label Placement Mode. How is the text drawn relative to the feature's geometry.
- OGR:LabelAnchor - Anchor Position. A value from 1 to 12 defining the label's position relative to the point to which it is attached. There are four vertical alignment modes: baseline, centre, top and bottom; and three horizontal modes: left, centre and right.
- OGR:LabelDx - X offset of the label's insertion point. Applies to text placed on a point, or at each vertex of a polyline.
- OGR:LabelDy - Y offset of the label's insertion point. Applies to text placed on a point, or at each vertex of a polyline.
- OGR:LabelPerp - Perpendicular Offset. For labels placed along a line. Specifies the perpendicular distance between the label and the line along which it is placed. If the offset is negative then the label will be shifted left of the main segment and right otherwise.
- OGR:LabelBold - Specifies whether the label is bold.
- OGR:LabelItalic - Specifies whether the label is italic.
- OGR:LabelUnderline - Specifies whether the label is underlined.
- OGR:LabelPriority - Priority Level. Numeric value defining the order in which style parts should be drawn. Lower priority style parts are drawn first, and higher priority ones are drawn on top.
If priority level is unspecified, the default is 1.
- OGR:LabelStrikeout - Specifies whether the label is striked out.
- OGR:LabelStretch - The stretch factor. The stretch factor changes the width of all characters in the font by factor percent. For example, setting factor to 150 results in all characters in the font being 1.5 times (i.e. 150%) wider. The default stretch factor is 100.
- OGR:LabelAdjHor - The horizontal adjustment of the label.
- OGR:LabelAdjVert - The vertical adjustment of the label.
- OGR:LabelHColor - Text Shadow Colour. Colour of the text shadow, expressed in hexadecimal (#RRGGBB[AA]).
- OGR:LabelOColor - Text Outline Colour. Colour of the text outline (halo in MapInfo terminology), expressed in hexadecimal (#RRGGBB[AA]).
By setting the Auto Style option in the Layer Property Editor all of the label properties are bound to the data source. However by using the label property binding you can bind only a subset of the attributes and specify the others manually.