
GeoServer Beginner's Guide

We will now come back to our countries data set to add labeling to the countries style. While most of the properties are what we already saw in the labeling of points and lines, we will add code to make halos around our labels. Halos could enhance readability of labels:
Take the Countries.xml
file, make a copy to CountriesLabeled.xml
, and then edit the new file in your text editor.
Go to line 9 and replace the text inside the Name
element with the following code snippet:
<Name>CountriesLabeled</Name>
Go to line 11 and replace the text inside the Title
element with the following code snippet:
<Title>Geoserver Beginners Guide: Countries with labels</Title>
Add a TextSymbolizer
element just after the PolygonSymbolizer
. Inside it, define the feature field containing the text and the font name and style to draw the label:
<TextSymbolizer> <Label> <ogc:PropertyName>NAME</ogc:PropertyName> ...
Change the font size
Change margin width
Change background colour