1

Is there any possibility to construct SLD style which displays label with rectangular background?

Background has to have sizes which automatically fit to sizes of text content. I would prefer not to use any vendor parameters because SLD has to be used in more than one application.

This is an example of desired label generated in QGIS (unfortunately QGIS doesn't export label specification from this label configuration):

enter image description here

  • Have you tried a <Halo> inside your <TextSymbolizer>? – Ralph Dell Dec 19 '13 at 15:31
3

I know you specified you would rather not use vendorparameters, but this is the only way I know how to do it. I'm not sure if you have tried this already.

Add a square graphic to the textsymbolizer and use the vendoroptions graphic-resize and graphic-margin.

      <TextSymbolizer>
        <Label>
         <ogc:PropertyName>NAME</ogc:PropertyName>
        </Label>
        <Font>
          <CssParameter name="font-weight">bold</CssParameter>
          <CssParameter name="font-size">15</CssParameter>
        </Font>
        <Fill>
          <CssParameter name="fill">#FFFFFF</CssParameter>
        </Fill>
       <Graphic>
          <Mark>
            <WellKnownName>square</WellKnownName>
            <Fill>
          <CssParameter name="fill">#DE230A</CssParameter>                  
            </Fill>
          </Mark>
        </Graphic>
        <VendorOption name="graphic-resize">stretch</VendorOption>                         
        <VendorOption name="graphic-margin">2</VendorOption>             
      </TextSymbolizer> 

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.