0

This question already has an answer here:

I am populating a tileWMS layer on my map (also created through Leaflet) through Leaflet from GeoServer which is working fine but the issue I am facing is with visibility of labels. On various zoom levels some labels are coming while some disappears, why is that happening?

Is this issue have something to do with the SLD or the Leaflet js library? Also, the issue exists only with a tiled WMS while the imageWMS works fine. Following is my SLD:

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
    xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd"
    xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
    xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <NamedLayer>
        <Name>polygon_with_label</Name>
        <UserStyle>
            <Title>A dark yellow polygon style</Title>
            <FeatureTypeStyle>
                <Rule>
                    <Title>dark yellow polygon</Title>
                    <PolygonSymbolizer>
                        <Fill>
                            <CssParameter name="fill">#<ogc:Function name="env">
                                    <ogc:Literal>fillcolor</ogc:Literal>
                                    <ogc:Literal>1dc159</ogc:Literal>
                                </ogc:Function></CssParameter>
                            <CssParameter name="fill-opacity">
                                <ogc:Function name="env">
                                    <ogc:Literal>fillopacity</ogc:Literal>
                                    <ogc:Literal>0.7</ogc:Literal>
                                </ogc:Function>
                            </CssParameter>
                        </Fill>
                        <Stroke>
                            <CssParameter name="stroke">#<ogc:Function name="env">
                                    <ogc:Literal>strokecolor</ogc:Literal>
                                    <ogc:Literal>000000</ogc:Literal>
                                </ogc:Function></CssParameter>
                            <CssParameter name="stroke-width">
                                <ogc:Function name="env">
                                    <ogc:Literal>strokewidth</ogc:Literal>
                                    <ogc:Literal>2</ogc:Literal>
                                </ogc:Function>
                            </CssParameter>
                        </Stroke>
                    </PolygonSymbolizer>
                    <TextSymbolizer>
                        <Geometry>
                            <ogc:Function name="centroid">
                                <ogc:PropertyName>the_geom</ogc:PropertyName>
                            </ogc:Function>
                        </Geometry>
                        <Label>
                            <ogc:PropertyName>label</ogc:PropertyName>
                        </Label>
                        <Halo>
                            <Radius>3</Radius>
                            <Fill>
                                <CssParameter name="fill">#FFFFFF</CssParameter>
                            </Fill>
                        </Halo>
                        <Font>
                            <CssParameter name="font-family">Arial</CssParameter>
                            <CssParameter name="font-size">
                                <ogc:Function name="env">
                                    <ogc:Literal>labelsize</ogc:Literal>
                                    <ogc:Literal>12</ogc:Literal>
                                </ogc:Function>
                            </CssParameter>
                            <CssParameter name="font-style">normal</CssParameter>
                            <CssParameter name="font-weight">bold</CssParameter>
                        </Font>
                        <LabelPlacement>
                            <PointPlacement>
                                <AnchorPoint>
                                    <AnchorPointX>0.5</AnchorPointX>
                                    <AnchorPointY>0.0</AnchorPointY>
                                </AnchorPoint>
                                <Displacement>
                                    <DisplacementX>0</DisplacementX>
                                    <DisplacementY>5</DisplacementY>
                                </Displacement>
                            </PointPlacement>
                        </LabelPlacement>
                        <Fill>
                            <CssParameter name="fill">#<ogc:Function name="env">
                                    <ogc:Literal>labelcolor</ogc:Literal>
                                    <ogc:Literal>000000</ogc:Literal>
                                </ogc:Function></CssParameter>
                        </Fill>
                    </TextSymbolizer>
                </Rule>
            </FeatureTypeStyle>
        </UserStyle>
    </NamedLayer>
</StyledLayerDescriptor>

marked as duplicate by Ian Turton geoserver Feb 15 at 8:21

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Your SLD is invalid: Invalid content was found starting with element '{"http://www.opengis.net/ogc":Function}'. One of '{"http://www.opengis.net/ogc":PropertyName}' is expected. (line 41) and Invalid content was found starting with element '{"http://www.opengis.net/sld":Font}'. One of '{"http://www.opengis.net/sld":Fill}' is expected. on line 52 – nmtoken Feb 15 at 14:03
  • Couldn't understand the issues you pointed in the SLD, can you please illaborate? – Gaurav Feb 15 at 20:16