1

I am using geoserver and sld : I want to make all labels visible at all zoom levels. How can I do that with SLD?

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0" 
    xsi:schemaLocation="http://www.opengis.net/sld 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>Attribute-based polygon</Name>
    <UserStyle>
      <Title>HAPPY FACE</Title>
      <FeatureTypeStyle>
      <Rule>
        <Name>min</Name>
        <Title>Data Unavailable</Title>
          <ogc:Filter>           
              <ogc:PropertyIsLessThan>
                <ogc:PropertyName>PS_GPRS_to_WCDMA_HOSR</ogc:PropertyName>
                <ogc:Literal>0</ogc:Literal>
              </ogc:PropertyIsLessThan>         
          </ogc:Filter>
         <PolygonSymbolizer>
           <Stroke>
             <CssParameter name="stroke">#000000</CssParameter>
             <CssParameter name="stroke-width">1</CssParameter>
           </Stroke>
          </PolygonSymbolizer>
        <TextSymbolizer>
            <Label>
              <ogc:PropertyName>Cluster</ogc:PropertyName>
            </Label>
            <Halo>
              <Radius>3</Radius>
              <Fill>
                <CssParameter name="fill">#FFFFFF</CssParameter>
              </Fill>
            </Halo>
          </TextSymbolizer>

      </Rule>
        <Rule>
          <Name>min</Name>
          <Title>From 0 Less than 92</Title>
          <ogc:Filter>
            <ogc:And>
              <ogc:PropertyIsGreaterThanOrEqualTo>
                <ogc:PropertyName>PS_GPRS_to_WCDMA_HOSR</ogc:PropertyName>
                <ogc:Literal>0</ogc:Literal>
              </ogc:PropertyIsGreaterThanOrEqualTo>
              <ogc:PropertyIsLessThan>
                <ogc:PropertyName>PS_GPRS_to_WCDMA_HOSR</ogc:PropertyName>
                <ogc:Literal>92</ogc:Literal>
              </ogc:PropertyIsLessThan>
          </ogc:And>
          </ogc:Filter>
          <PolygonSymbolizer>
            <Fill>
              <CssParameter name="fill">#2C6700</CssParameter>
            </Fill>
          </PolygonSymbolizer>
      <TextSymbolizer>
            <Label>
              <ogc:PropertyName>Cluster</ogc:PropertyName>
            </Label>
            <Halo>
              <Radius>3</Radius>
              <Fill>
                <CssParameter name="fill">#FFFFFF</CssParameter>
              </Fill>
            </Halo>
          </TextSymbolizer>
        </Rule>
        <Rule>
          <Name>PS_GPRS_to_WCDMA_HOSR</Name>
          <Title>From 92 Less Than 94</Title>
          <ogc:Filter>
            <ogc:And>
              <ogc:PropertyIsGreaterThanOrEqualTo>
                <ogc:PropertyName>PS_GPRS_to_WCDMA_HOSR</ogc:PropertyName>
                <ogc:Literal>92</ogc:Literal>
              </ogc:PropertyIsGreaterThanOrEqualTo>
              <ogc:PropertyIsLessThan>
                <ogc:PropertyName>PS_GPRS_to_WCDMA_HOSR</ogc:PropertyName>
                <ogc:Literal>94</ogc:Literal>
              </ogc:PropertyIsLessThan>
            </ogc:And>
          </ogc:Filter>
          <PolygonSymbolizer>
            <Fill>
              <CssParameter name="fill">#004040</CssParameter>
            </Fill>
          </PolygonSymbolizer>
      <TextSymbolizer>
            <Label>
              <ogc:PropertyName>Cluster</ogc:PropertyName>
            </Label>
            <Halo>
              <Radius>3</Radius>
              <Fill>
                <CssParameter name="fill">#FFFFFF</CssParameter>
              </Fill>
            </Halo>
          </TextSymbolizer>
        </Rule>
    <Rule>
          <Name>third_PS_GPRS_to_WCDMA_HOSR</Name>
          <Title>From 94 Less Than 95</Title>
          <ogc:Filter>
            <ogc:And>
              <ogc:PropertyIsGreaterThanOrEqualTo>
                <ogc:PropertyName>PS_GPRS_to_WCDMA_HOSR</ogc:PropertyName>
                <ogc:Literal>94</ogc:Literal>
              </ogc:PropertyIsGreaterThanOrEqualTo>
              <ogc:PropertyIsLessThan>
                <ogc:PropertyName>PS_GPRS_to_WCDMA_HOSR</ogc:PropertyName>
                <ogc:Literal>95</ogc:Literal>
              </ogc:PropertyIsLessThan>
            </ogc:And>
          </ogc:Filter>
          <PolygonSymbolizer>
            <Fill>
              <CssParameter name="fill">#D0CA9C</CssParameter>
            </Fill>
          </PolygonSymbolizer>
      <TextSymbolizer>
            <Label>
              <ogc:PropertyName>Cluster</ogc:PropertyName>
            </Label>
            <Halo>
              <Radius>3</Radius>
              <Fill>
                <CssParameter name="fill">#FFFFFF</CssParameter>
              </Fill>
            </Halo>
          </TextSymbolizer>
        </Rule>

        <Rule>
          <Name>Large_PS_GPRS_to_WCDMA_HOSR</Name>
          <Title>Greater Than 95</Title>
          <ogc:Filter>
            <ogc:PropertyIsGreaterThan>
              <ogc:PropertyName>PS_GPRS_to_WCDMA_HOSR</ogc:PropertyName>
              <ogc:Literal>98.5</ogc:Literal>
            </ogc:PropertyIsGreaterThan>
          </ogc:Filter>
          <PolygonSymbolizer>
            <Fill>
              <CssParameter name="fill">#000000</CssParameter>
            </Fill>
          </PolygonSymbolizer>
      <TextSymbolizer>
            <Label>
              <ogc:PropertyName>Cluster</ogc:PropertyName>
            </Label>
            <Halo>
              <Radius>3</Radius>
              <Fill>
                <CssParameter name="fill">#FFFFFF</CssParameter>
              </Fill>
            </Halo>
          </TextSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

enter image description here

items.push({
                xtype: "gx_mappanel",
                ref: "mapPanel",            
                region: "center",            
                map: {      
                    numZoomLevels: 19,                
                    controls: controls                   
                },
                zoom:8,
                center:[lon,lat],                
               layers: [               

                new OpenLayers.Layer.WMS( "TBF Drop Rate DL ",

                url, 

                {layers: 'NCellGisData:TBF_DROP_RATE_DL_DAILY' ,transparent: "true",format: "image/png",tiled:"yes"},

                { 

                    buffer: 0,

                    isBaseLayer :true,

                    tiled: true

                }

            )



            ]

            });
2

Also have a look at the max displacement and goodness of fit labelling parameters:

http://docs.geoserver.org/latest/en/user/styling/sld-reference/labeling.html#maxdisplacement

2

There is no reference to scale (scaledenominator) in the SLD file you have attached so all your rules (and hence all the labels) will fire at all scales.

From the image you've included it looks more like a problem with your tiles being small in respect to your polygons and labels. By default GeoServer will put the label at the polygon centroid and not draw the label if that centroid falls outside the draw area. You might try adding the tiled parameter to see if that helps.

UPDATE

That is a different tiled parameter than the OpenLayers one you have set - see below:

new OpenLayers.Layer.WMS( "TBF Drop Rate DL",
                    url, 
                    {layers: 'NCellGisData:tbf_drop_rate_dl_daily' ,transparent:   "true",format: "image/png",
      tiled:"yes"},//add this parameter 
                    { 
                        buffer: 0,
                        isBaseLayer :true,
                        tiled:true
                    }
  • tried that too but still it doesn't show labels till I zoom – kinkajou Jul 3 '12 at 13:51
  • try turning tiling off completely to check if this is the issue – Ian Turton Jul 3 '12 at 18:25
  • do you mean tiled:true parameter ! if so i did that? Are there any other way to turn it off. – kinkajou Jul 4 '12 at 8:36
  • I have the same problem. My labels only show up when I very much zoomed in. Is there a way to make this work in the default geoserver layer preview map? I don't feel like messing with the code in geoserver. Is there a setting I could use in geoserver? – Freeze Mar 28 '14 at 16:22

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.