I am trying to get labels to follow the linestring. I have inserted the following sld text into a geoserver style, but the label is displayed at the horizontally at linestring centroid


          <ogc:Function name="centroid">


          <sld:CssParameter name="font-family">MS Shell Dlg 2</sld:CssParameter>
          <sld:CssParameter name="font-size">6.0</sld:CssParameter>
          <sld:CssParameter name="font-style">normal</sld:CssParameter>
          <sld:CssParameter name="font-weight">normal</sld:CssParameter>


                <CssParameter name="fill">#FFFFFF</CssParameter>
                <CssParameter name="fill-opacity">0.85</CssParameter>               

          <sld:CssParameter name="fill">#000000</sld:CssParameter>

       <sld:VendorOption name="followLine">true</sld:VendorOption>


I thought that by adding the VendorOption -> "followLine" the label would be displayed inline with the line. Is there something that i have missed in the documentation to make this work?


You must remove the geometry transformation turning the line into a point:

      <ogc:Function name="centroid">

With the above in, the code is labelling a point, not a line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.