If there is a demand, a point at a certain scale displays a small solid dot, and then zoom in to display a certain scale circular img icon, so how to achieve it? This use to MinScaleDenominator
and MaxScaleDenominator
label use of these two labels to note the following three points:
- Both labels should be placed
Rule
label use - The two tags may be used alone,
MinScaleDenominator
it represents a value greater than this time scale, corresponding to the use of Rule;MaxScaleDenominator
when less than this value represents the scale, corresponding to the use of Rule MinScaleDenominator
AndMaxScaleDenominator
it can be used simultaneously, writing position in no particular order
Now we are beginning to achieve the mentioned requirements, complete code is as follows:
<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/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>chargesite</Name>
<UserStyle>
<Title>gold square point style</Title>
<FeatureTypeStyle>
<Rule>
<MinScaleDenominator>400000</MinScaleDenominator>
<MaxScaleDenominator>1200000</MaxScaleDenominator>
<PointSymbolizer>
<Graphic>
<Mark>
<WellKnownName>circle</WellKnownName>
<Fill>
<CssParameter name="fill">#00ff00</CssParameter>
</Fill>
</Mark>
<Size>6</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<MaxScaleDenominator>400000</MaxScaleDenominator>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource xlink:type="simple" xlink:href="charge_site.png" />
<Format>image/png</Format>
</ExternalGraphic>
<Size><ogc:Literal>16</ogc:Literal></Size>
</Graphic>
</PointSymbolizer>
<TextSymbolizer>
<Label>
<ogc:PropertyName>stationName</ogc:PropertyName>
</Label>
<Font>
<CssParameter name="font-family">微软雅黑</CssParameter>
<CssParameter name="font-size">13</CssParameter>
<CssParameter name="font-style">normal</CssParameter>
<CssParameter name="font-weight">bold</CssParameter>
</Font>
<LabelPlacement>
<PointPlacement>
<AnchorPoint>
<AnchorPointX>0</AnchorPointX>
<AnchorPointY>0</AnchorPointY>
</AnchorPoint>
<Displacement>
<DisplacementX>12</DisplacementX>
<DisplacementY>0</DisplacementY>
</Displacement>
</PointPlacement>
</LabelPlacement>
<Fill>
<CssParameter name="fill">#00ff00</CssParameter>
</Fill>
</TextSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
Effect:
1, when the zoom ratio is greater than 1.2 million, the point is not displayed:
2, when the zoom ratio from 400,000 to 1,200,000, the green dot:
3, when the zoom ratio is less than 400,000, display the specified picture: