Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to label a layer of line vectors using SLD in Geoserver. It is simple enough, and it's pretty much copied from the SLD cookbook:

The thing that's getting me is that when I view the Openlayers preview in Geoserver, everything seems to render correctly. Each road is only labeled once and it's not extremely busy looking. However, when I import the layer via WMS to my Openlayers map, it doesn't seem to recognize this line:

<VendorOption name="repeat">400</VendorOption> 

Which is supposed to keep it from repeating within 400 pixels.

I've also tried:

<VendorOption name="group">yes</VendorOption> 

Which should only display a single label on a map per unique text.

Any idea what is going on here? I need the labels to look like the Geoserver preview.

Map displayed in openlayers after importing layer via WMS: WMS Served Map

Map displayed in Geoserver Openlayers preview: Openlayers preview

<?xml version="1.0" encoding="UTF-8"?> <StyledLayerDescriptor version="1.0.0" xsi:schemaLocation=" StyledLayerDescriptor.xsd" xmlns="" xmlns:ogc="" xmlns:xlink="" xmlns:xsi=""> <NamedLayer> <Name>Roads</Name> <UserStyle> <FeatureTypeStyle> <Rule> <Title>Roads</Title> <LineSymbolizer> <Stroke> <CssParameter name="stroke"> <ogc:Literal>#000000</ogc:Literal> </CssParameter> <CssParameter name="stroke-width"> <ogc:Literal>1</ogc:Literal> </CssParameter> </Stroke> </LineSymbolizer> <TextSymbolizer> <Label> <ogc:PropertyName>name</ogc:PropertyName> </Label> <LabelPlacement> <LinePlacement> <PerpendicularOffset> 10 </PerpendicularOffset> </LinePlacement> </LabelPlacement> <Fill> <CssParameter name="fill">#000000</CssParameter> </Fill> <VendorOption name="repeat">400</VendorOption> </TextSymbolizer> </Rule> </FeatureTypeStyle> </UserStyle> </NamedLayer> </StyledLayerDescriptor>

share|improve this question
up vote 2 down vote accepted

This is probably an artifact due to tiling. The layer preview map defaults to a single tile, but I'm guessing your openlayers map uses tiling.

Geoserver insists on labeling every tile. GeoServer doesn't know that each request is for a tile in a larger map, so it treats a tile as a complete map and dutifully applies a label to it. So basically, if a road stretches across three tiles, it will be labelled three times.

Unfortunately, there's not much you can do about it. I was advised to enable meta-tiling. This does allow GeoServer to think of requests as tile components to some extent, and this can minimise the label repeating. However, I believe it's on by default in recent versions.

share|improve this answer
You are right, it is due to tiling. I found that in the Openlayers preview you can click the button in the top left in order to change it to single tile or tiled; when changing to tiled it showed the same problems. This is how I resolved it: When adding the WMS layer in openlayers, you have to specify the "tiled: true, tilesorigin: [map.maxExtent.left, map.maxExtent.bottom]" parameters. Finally, in the Geoserver layer tile caching tab, you can change the metatiling factors to something larger than 4x4. – scavok Jul 21 '14 at 8:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.