1

I have everything working on my geoserver except for the labeling. I have searched and I cannot find any solution. I am by no means an expert.

I can modify the look/symbology of my polygons, lines, etc... but when I add a style that utilizes a label, nothing shows up on my map. I have created new labels with the sld files I downloaded directly from geoserver docs. I also changed the attribute field name that I want to use in my shapefile as the label. When I open the layer on the map, nothing shows up, not even the polygon.

I am sure I have not enabled something. Any help would be appreciated...

geoserver 2.4.1

Here is the sld I have recently tried:

http://docs.geoserver.org/stable/en/user/styling/sld-cookbook/polygons.html#label-halo

<?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>Label halo</Name>
    <UserStyle>
      <Title>SLD Cook Book: Label halo</Title>
      <FeatureTypeStyle>
        <Rule>
          <PolygonSymbolizer>
            <Fill>
              <CssParameter name="fill">#40FF40</CssParameter>
            </Fill>
            <Stroke>
              <CssParameter name="stroke">#FFFFFF</CssParameter>
              <CssParameter name="stroke-width">2</CssParameter>
            </Stroke>
          </PolygonSymbolizer>        
          <TextSymbolizer>
            <Label>
              <ogc:PropertyName>name</ogc:PropertyName>
            </Label>
            <Halo>
              <Radius>3</Radius>
              <Fill>
                <CssParameter name="fill">#FFFFFF</CssParameter>
              </Fill>
            </Halo>
          </TextSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>
  • Are you sure Times New Roman is available for Geoserver installation? You might check it in Geoserver admin pages. Is it a valid SLD schema by the way? – Michal Zimmermann Nov 16 '13 at 21:30
  • Thanks for the reply zimmi. I pasted the wrong code in my question. I edited my code above with the correct SLD. I got that SLD from the geoserver user docs. – DWall Nov 16 '13 at 22:48
2

Check the case of the field name, Postgres treats 'name' and 'NAME' as totally different fields, if the field is not found, the style will not show and there will be an error in your GeoServer log file

  • Mark, thanks for the response. I have verified multiple times that the field "name" is correct. I have also tried numerous other fields with no luck. If I take this line <ogc:PropertyName>name</ogc:PropertyName> out of the SLD code, the polygons show on the map. Once I add that line, nothing shows up on the map. I know for sure that I am matching the field name case for case. This sucks!!! – DWall Nov 18 '13 at 0:16
  • This was a gotcha for me some time ago, hence the answer. Are you using a database or shapeFile? Can you post the schema from Postgres or open the Dbf File in the Shape File in Excel and Post a screenshot of the field names? or even better, a screen shot of the layer set up page that lists the fields – Mark Cupitt Nov 18 '13 at 0:31
  • Also, look at your GeoServer Log file, right after you make a call to the layer. It will show any errors generated that cause the style to fail. – Mark Cupitt Nov 18 '13 at 0:32

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.