在geoserver中我們可以使用sld樣式,sld是OGC指定的標准,說實在直接寫樣式比較麻煩,我們可以通過Udig或者Qgis進行配置然后發布,但是有時候我們想圖片或者svg或者gif進行填充,這時候我們就不得不屑sld樣式了,廢話不多說進入正題
一、用到標簽
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="xiaohuangya2.svg" />
<Format>image/svg</Format>
</ExternalGraphic>
<Size>22</Size>
</Graphic>
</PointSymbolizer>
關於OnlineResource和Format詳解
二、sid示例
<?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>Point as graphic</Name>
<UserStyle>
<Title>GeoServer SLD Cook Book: Point as graphic</Title>
<FeatureTypeStyle>
<Rule>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="xiaohuangya2.svg" />
<Format>image/svg</Format>
</ExternalGraphic>
<Size>22</Size>
</Graphic>
</PointSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
關於xlink:href路徑填的位置,這里用相對路徑放在"**D:\軟件安裝\geoserver2.15\GeoServer 2.15.0\data_dir\workspaces\cite\styles\xiaohuangya2.svg"**相對路徑一定要放在這,否則geoserver控制台出現下面的錯誤
也就是找不到圖片的位置
參考文章:sld應用
geoserver關於sld
阿里圖標
效果圖