I have set up GeoServer with PostgreSQL/PostGIS as database.
Imported a country boundary shapefile into the database and published as WMS.
The data has got the Country name attribute in the "label" column.
I setup a map client using Openlayers, and it shows so many labels when zoomed in, one for each tile.
Can I publish the wms map as a Single Image, (without multiple image tiles) to avoid duplicate country name labels?
Or is there any other successful methods to do this in SLD?
I have read many answers and tried vendor options to correct this, nothing worked.
Some similar questions were seen as removed as duplicates, but sincerely, I got no solution for this duplicate label issue in GeoServer.
More Info:
I am using GeoServer 2.7.0
Using openlayers javascript from :
And the Openlayers code is:
<script type="text/javascript"> var map; function init() { map = new OpenLayers.Map({ div: "map", projection: new OpenLayers.Projection("EPSG:900913"), controls: [], numZoomLevels: 8, maxZoomLevel: 16 }); var osm = new OpenLayers.Layer.OSM("Open Street"); var gmap = new OpenLayers.Layer.Google("Google Streets");
Layer1 = new OpenLayers.Layer.WMS("1648", "http://localhost:8080/geoserver/wms",
{ layers: 'my_wor:Layer1', transparent: true },
{ isBaseLayer: false });
Layer2 = new OpenLayers.Layer.WMS("2015", "http://localhost:8080/geoserver/wms",
{ layers: 'my_wor:Layer2', transparent: true },
{ isBaseLayer: false });
map.addLayers([gmap, osm, Layer1, Layer2]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.ScaleLine());
map.addControl(new OpenLayers.Control.OverviewMap());
map.addControl(new OpenLayers.Control.Navigation());
map.addControl(new OpenLayers.Control.PanZoomBar());
</script>
See the SLD below, with the vendor options "group" is given true.
<?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>Polygon with styled label</Name>
<UserStyle>
<Title>SLD Cook Book: Polygon with styled label</Title>
<FeatureTypeStyle>
<Rule>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">#FF0000</CssParameter>
</Fill>
<Stroke>
<CssParameter name="stroke">#CCCCCC</CssParameter>
<CssParameter name="stroke-width">1</CssParameter>
</Stroke>
</PolygonSymbolizer>
<TextSymbolizer>
<Label>
<ogc:PropertyName>label</ogc:PropertyName>
</Label>
<Font>
<CssParameter name="font-family">Arial</CssParameter>
<CssParameter name="font-size">12</CssParameter>
<CssParameter name="font-style">normal</CssParameter>
<CssParameter name="font-weight">bold</CssParameter>
</Font>
<LabelPlacement>
<PointPlacement>
<AnchorPoint>
<AnchorPointX>0.5</AnchorPointX>
<AnchorPointY>0.5</AnchorPointY>
</AnchorPoint>
</PointPlacement>
</LabelPlacement>
<Fill>
<CssParameter name="fill">#000000</CssParameter>
</Fill>
<VendorOption name="autoWrap">160</VendorOption>
<VendorOption name="repeat">0</VendorOption>
<VendorOption name="group">true</VendorOption>
<VendorOption name="labelAllGroup">false</VendorOption>
</TextSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>