geoserver中sld样式小试牛刀之给图层添加注记

以前没有太注重SLD,应该说用的很少,SLD是OGC定义的标准,非常好用,使用xml去写官网给出了许多使用的案例,我们在此基础上改动即可,达到自己项目所要求的效果,你可以进行各种渲染,在arcgis api 哪几种渲染用这个基本都可以达到同样的效果,是不是很神奇。

来张图:

一、结构示例

TextSymbolizer

 

……Label

 

………ogc:PropertyName

注记的属性字段名称

……Font

字体

………CssParameter  name=”font-family”

字体类型

………CssParameter  name=”font-size”

字体大小

………CssParameter  name=”font-style”

字体样式

………CssParameter  name=”font-weight”

字体加粗

……LabelPlacement

注记的位置

………PointPlacement

注记点位置

…………AnchorPoint

 

……………AnchorPointX

 

……………AnchorPointY

 

…………Displacement

 

……………Displacement X

 

……………Displacement Y

 

…………Rotation

设置旋转角度

……Fill

填充

………CssParameter  name=”fill”

填充颜色

二、简单demo

<?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>render</Name>
    <UserStyle>
      <Title>render</Title>
      <Abstract>A heatmap surface showing population density</Abstract>
      <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>
            <Font>
              <CssParameter name="font-family">微软雅黑</CssParameter>
              <CssParameter name="font-size">11</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">60</VendorOption>
            <VendorOption name="maxDisplacement">150</VendorOption>
          </TextSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

 

转载自:https://blog.csdn.net/weixin_40184249/article/details/83351306

You may also like...