Geoserver的样式一(点的样式之文本编辑)

    主要实现了geoserver中点元素的样式规则:

<?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">
  <!-- a Named Layer is the basic building block of an SLD document -->
  <NamedLayer>
    <Name>experimenting transparent</Name>
    <UserStyle>
    <!-- Styles can have names, titles and abstracts -->
      <Title>GeoServer Beginners Guide:transparent</Title>
      <Abstract>A sample style that draws a point</Abstract>
      <!-- FeatureTypeStyles describe how to render different features -->
      <!-- A FeatureTypeStyle for rendering points -->
      <FeatureTypeStyle>
        <Rule>
          <Name>rule1</Name>
          <Title>Red Square</Title>
          <Abstract>A 6 pixel square with a red fill and no stroke</Abstract>
          <MaxScaleDenominator>40000</MaxScaleDenominator><!--设置点跟着比例次的显示效果-->

          <PointSymbolizer>
              <Graphic><!--这里可以设置为一个图片的格式-->
                <Mark>
                  <WellKnownName>square</WellKnownName>
                  <Fill>
                    <CssParameter name="fill">#CFF000</CssParameter>
                    <CssParameter name="fill-opacity">0.35</CssParameter>
                  </Fill>
                  <Stroke>
                    <CssParameter name="stroke">#FF0000</CssParameter>
                    <CssParameter name="stroke-width">1</CssParameter>
                  </Stroke>
                </Mark>
              <Size>9</Size>
              <Rotation>45</Rotation>
            </Graphic>
          </PointSymbolizer>
          
          <TextSymbolizer>
          	<Label>
          		<ogc:PropertyName>NAME</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">italyc</CssParameter>
          	</Font>
          	
          	<LabelPlacement>          	
	          	<PointPlacement>
	          		<AnchorPoint>
	          			<AnchorPointX>0</AnchorPointX>
	          			<AnchorPointY>0</AnchorPointY>
	          		</AnchorPoint>
	          		<Displacement>
	          			<DisplacementX>2</DisplacementX>
	          			<DisplacementY>5</DisplacementY>
	          		</Displacement>
	          	</PointPlacement>
          	</LabelPlacement>
          	
          	<Fill>
          		<CssParameter name="fill">#000000</CssParameter>
          	</Fill>
        	</TextSymbolizer>  
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>


转载自:https://blog.csdn.net/whynottrythis/article/details/21322709

You may also like...