TransWikia.com

How to change placement for label of a polygon in mapserver with SLD

Geographic Information Systems Asked on February 22, 2021

I want to change the placement of the label of special polygon by sending SLD to WMS of Mapserver. But it seems as it has no effect. Is label placement in polygons support by mapserver?

        <TextSymbolizer>
        <Font>
            <CssParameter name="font-family">arial</CssParameter>
            <CssParameter name="font-size">20</CssParameter>
        </Font>
        <LabelPlacement>
            <PointPlacement>
                <AnchorPoint>
                    <AnchorPointX>0</AnchorPointX>
                    <AnchorPointY>0</AnchorPointY>
                </AnchorPoint>
                <Displacement>
                  <DisplacementX>0</DisplacementX>
                  <DisplacementY>50</DisplacementY>
                </Displacement>
            </PointPlacement>
        </LabelPlacement>
        <Fill>
            <CssParameter name="fill">#000000</CssParameter>
        </Fill>
    </TextSymbolizer>

One Answer

I found out, that I missed the label-TAG with PropertyName:

<TextSymbolizer>
    <Label>
        <PropertyName>name</PropertyName>
    </Label>
    <Font>
        <CssParameter name="font-family">arial</CssParameter>
        <CssParameter name="font-size">20</CssParameter>
    </Font>
    <LabelPlacement>
        <PointPlacement>
            <AnchorPoint>
                <AnchorPointX>0.5</AnchorPointX>
                <AnchorPointY>0.5</AnchorPointY>
            </AnchorPoint>
            <Displacement>
                <DisplacementX>0</DisplacementX>
                <DisplacementY>50</DisplacementY>
            </Displacement>
        </PointPlacement>
    </LabelPlacement>
    <Fill>
        <CssParameter name="fill">#000000</CssParameter>
    </Fill>
</TextSymbolizer>

Correct answer by Max on February 22, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP