1

I am pretty new to GeoServer. I am trying to make a style with dynamic labeling. Currently, I am using env to label multiple attributes, but I don't know how to change the color for each of the attributes that I made. Heres the SLD that I made. Is there any way for me to have color red for attr0 and blue for attr1?

          <TextSymbolizer>
            <Geometry>
              <ogc:Function name="centroid">
                <ogc:PropertyName>the_geom</ogc:PropertyName>
              </ogc:Function>
            </Geometry>

            <Label>
              <ogc:Function name="property">
                <ogc:Function name="env">
                  <ogc:Literal>attr0</ogc:Literal>
                  <ogc:Literal>0</ogc:Literal>
                </ogc:Function>
              </ogc:Function><![CDATA[
]]>              
              <ogc:Function name="property">
                <ogc:Function name="env">
                  <ogc:Literal>attr1</ogc:Literal>
                  <ogc:Literal>0</ogc:Literal>
                </ogc:Function>
              </ogc:Function><![CDATA[
]]>
            <Font>
              <CssParameter name="font-family">Arial</CssParameter>
              <CssParameter name="font-size">
                <ogc:Function name="Categorize">
                  <!-- Value to transform -->
                  <ogc:Function name="env">
                    <ogc:Literal>wms_scale_denominator</ogc:Literal>
                  </ogc:Function>
                  <ogc:Literal>10</ogc:Literal>
                  <ogc:Literal>3000</ogc:Literal>
                  <ogc:Literal>10</ogc:Literal>
                  <ogc:Literal>30000</ogc:Literal>
                  <ogc:Literal>5</ogc:Literal>
                </ogc:Function>
              </CssParameter>
              <CssParameter name="font-style">normal</CssParameter>
            </Font>
            <Fill>
              <CssParameter name="fill">#ff0000</CssParameter>
            </Fill>
          </TextSymbolizer>

1

There is currently no way to change the color inside the same label. You can try creating multiple text symbolizers and place them close enough, but you're going to have issues with parts being visible while others do not show, due to conflict resolution

If I had to do it, maybe some limited HTML support would be the way... it's work that needs sponsoring anyways.

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.