Time for action – labeling lines
Place names are useful but a road map without a road name, or at least road codes, is almost useless. You need to get back to the roads style and add code to enable road labeling:
Take the
Roads.xml
file, make a copy toRoadsLabeled.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>RoadsLabeled</Name>
Go to line 11 and replace the text inside the
Title
element with the following code snippet:<Title>Geoserver Beginners Guide: Roads with labels along the line</Title>
Remove the last
LineSymbolizer
, from line 26 to 31. We need a simpler symbol to have a pretty map.Set the width of black line to
4
:<CssParameter name="stroke-width">4</CssParameter>
Set the width of red line to
2
:<CssParameter name="stroke-width">4</CssParameter>
After the last
LineSymbolizer
, add a newTextSymbolizer
element. Inside it, you...