To style labels with SLD, you can use a TextSymbolizer, which includes settings to configure the label content, the label location, and styling settings such as the font and the color. To enhance the readability of labels, users commonly want to add a box around a label. LuciadRIA supports OGC SE standard 1.1, which doesn’t offer this capability. LuciadRIA does support label boxing, by means of an SE extension, though.

To add a box around label text:

  1. Add the well-known mark square as a graphic to the TextSymbolizer. You can configure the desired stroke and fill settings for the box on the graphic.

  2. Add the vendor option graphic-resize=stretch to the TextSymbolizer. With this setting, you make sure to stretch the well-known mark square to contain the label.

  3. Add the vendor option graphic-margin to the TextSymbolizer. This vendor option takes an integer value to represent the desired padding in pixels between the label and its box.

LuciadRIA supports regular stretched square boxes only. If you use other graphics or other resize possibilities, LuciadRIA shows you a warning and skips them without generating a label box. There is no support for label boxes for world-sized text.

Program: Defining a text style with a box shows you an example of adding a label with a box to a line geometry:

Figure 1. The resulting line with a label in a box from the SLD below.
Program: Defining a text style with a box
<?xml version='1.0' encoding='UTF-8'?>
<FeatureTypeStyle xmlns=""
        <SvgParameter name="font-style">normal</SvgParameter>
        <SvgParameter name="font-weight">normal</SvgParameter>
        <SvgParameter name="font-size">10</SvgParameter>
        <SvgParameter name="font-family">Lucida Sans</SvgParameter>
            <SvgParameter name="fill-opacity">1.0</SvgParameter>
            <SvgParameter name="fill">#FFFF00</SvgParameter>
            <SvgParameter name="stroke-opacity">1.0</SvgParameter>
            <SvgParameter name="stroke">#0000FF</SvgParameter>
            <SvgParameter name="stroke-width">3</SvgParameter>
      <VendorOption name="graphic-resize">stretch</VendorOption>
      <VendorOption name="graphic-margin">4</VendorOption>
        <SvgParameter name="stroke-width">1</SvgParameter>
        <SvgParameter name="stroke">#FF0000</SvgParameter>
        <SvgParameter name="stroke-opacity">1.0</SvgParameter>