现在的位置: 首页 > 综合 > 正文

SLD 样式 之 labels with graphics

2012年08月04日 ⁄ 综合 ⁄ 共 1748字 ⁄ 字号 评论关闭

        最近在配地图的样式,遇到一个问题,就是像 的道路lables不知如何定义,在网上几番搜索发现lables中得

<TextSymbolizer>标签中也可以添加 <Graphic>标签。
具体sld样式如下:
 1  <TextSymbolizer>
2 <Label>
3 <ogc:PropertyName>name</ogc:PropertyName>
4 </Label>
5 <Font>
6 <CssParameter name="font-family">宋体</CssParameter>
7 <CssParameter name="font-size">12</CssParameter>
8 <CssParameter name="font-weight">bold</CssParameter>
9 </Font>
10 <LabelPlacement>
11 <PointPlacement>
12 <AnchorPoint>
13 <AnchorPointX>0.5</AnchorPointX>
14 <AnchorPointY>0.5</AnchorPointY>
15 </AnchorPoint>
16 </PointPlacement>
17 </LabelPlacement>
18 <Fill>
19 <CssParameter name="fill">#FFFFFF</CssParameter>
20 </Fill>
21 <Graphic>
22 <Mark>
23 <WellKnownName>square</WellKnownName>
24 <Fill>
25 <CssParameter name="fill">#59BF34</CssParameter>
26 </Fill>
27 <Stroke>
28 <CssParameter name="stroke">#2D6917</CssParameter>
29 </Stroke>
30 </Mark>
31 <Size>24</Size>
32 </Graphic>
33 <VendorOption name="graphic-resize">stretch</VendorOption>
34 <VendorOption name="graphic-margin">3</VendorOption>
35 <VendorOption name="group">true</VendorOption>
36 <VendorOption name="repeat">200</VendorOption>
37 <VendorOption name="maxDisplacement">50</VendorOption>
38 </TextSymbolizer>


 其中graphic-resize模式有如下三种: none,proportional, stretch

效果:                      

要实现或更漂亮的背景可以使用<ExternalGraphic>

<ExternalGraphic>
<OnlineResource xlink:type="simple"
xlink:href
="http://......jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>

 

相应的在<LineSymbolizer> 和<PolygonSymbolizer>

也可以添加<Graphic>标签

 

<LineSymbolizer>
<Stroke>
<GraphicStroke>
<Graphic>
<Mark>
<WellKnownName>shape://vertline</WellKnownName>
<Stroke/>
</Mark><Size>7</Size>
</Graphic>
</GraphicStroke>
</Stroke>
</LineSymbolizer>
<PolygonSymbolizer>
<Fill>
<GraphicFill><Graphic>
<Mark>
<WellKnownName>shape://slash</WellKnownName>
<Stroke />
</Mark><Size>10</Size>
</Graphic></GraphicFill>
</Fill>
<Stroke/>
</PolygonSymbolizer>


【上篇】
【下篇】

抱歉!评论已关闭.