Putting the graphic inside the textsymbolizer the label does appear on top of 
the graphic. Otherwise, try the other option instead: two symbolizers for the 
polygon both generating a point geometry. You may want to calculate the point 
geometry of the polygon beforehand in the database to be sure the same point is 
used for both the TexstSymbolizer and the PointSymbolizer. With the proper 
displacement values, this should work okay.

This is a piece of SLD I used for a table with railway stations with a point 
geometry. It draws the label above the station icon

<PointSymbolizer>

    <Graphic>

        <ExternalGraphic>

            <OnlineResource xlink:type="simple" 
xlink:href="/home/gisuser/symbols/station2.png"/>

            <Format>image/png</Format>

        </ExternalGraphic>

    </Graphic>

</PointSymbolizer>

<TextSymbolizer>

    <Label>Station<![CDATA[
        ]]><ogc:PropertyName>name</ogc:PropertyName>

    </Label>

    <Font>

        <CssParameter name="font-family">Arial</CssParameter>
        <CssParameter name="font-weight">bold</CssParameter>

        <CssParameter name="font-size">10</CssParameter>

    </Font>

    <LabelPlacement>

        <PointPlacement>

            <AnchorPoint>

                <AnchorPointX>0.5</AnchorPointX>

                <AnchorPointY>0</AnchorPointY>

            </AnchorPoint>

            <Displacement>

                <DisplacementX>0</DisplacementX>

                <DisplacementY>10</DisplacementY>

            </Displacement>

        </PointPlacement>

    </LabelPlacement>

    <Fill>

        <CssParameter name="fill">#000000</CssParameter>

    </Fill>

</TextSymbolizer>

Date: Mon, 29 Oct 2012 15:38:09 +0530
Subject: Re: [Geoserver-users] Polygon label with graphic
From: maney1...@gmail.com
To: geoserver-users@lists.sourceforge.net
CC: emacgilla...@hotmail.com

Edward,
Both options works for me, but labelplacement seems to be NOT working in both 
cases. Label appears just over the image. Is there any way to fix 
labelplacement ?

On Mon, Oct 29, 2012 at 12:59 AM, Edward Mac Gillavry 
<emacgilla...@hotmail.com> wrote:





Hiya,

Check out the interiorPoint function as discussed in this thread 
http://permalink.gmane.org/gmane.comp.gis.geoserver.user/33677. Thus, you 
explicitly define a point geometry to be used to position the graphic and the 
label.


Also, you can reference a graphic inside a TextSymbolizer, an approach 
typically used for creating highway shields:

<TextSymbolizer>
    <Label>
        <ogc:PropertyName>NAME</ogc:PropertyName>

    </Label>    
    <LabelPlacement>
        <PointPlacement>
            <AnchorPoint>
                <AnchorPointX>0.5</AnchorPointX>
                <AnchorPointY>1</AnchorPointY>

            </AnchorPoint>
            <Displacement>
                <DisplacementX>0</DisplacementX>
                <DisplacementY>-10</DisplacementY>
            </Displacement>

        </PointPlacement>
    </LabelPlacement>
    <Fill>
        <CssParameter name="fill">#000000</CssParameter>
    </Fill>
    <Graphic>

        <ExternalGraphic>
            <OnlineResource
                xlink:type="simple"
                 xlink:href="file:///C:/Subramanian/reficons/park.jpg"    />
            <Format>image/jpeg</Format>

         </ExternalGraphic>
     </Graphic>
</TextSymbolizer>

Regards,

Edward

Date: Sun, 28 Oct 2012 20:30:38 +0530
From: maney1...@gmail.com

To: geoserver-users@lists.sourceforge.net
Subject: [Geoserver-users] Polygon label with graphic

Hi,
I have a polygon layer, which I want to label it WITH a jpg file. I am NOT able 
to display jpg file and label along with it. Label and jpg is appearing at 
different place on the map.
Is it possible to label polygon with jpg file ?á

Following is the contents of sld file,
<PolygonSymbolizer>

á á á áá<Fill>

á á á á áá<CssParameteráname="fill">#c9dfaf</CssParameter>

á á á áá</Fill>

á á á áá<Stroke>

á á á á áá<CssParameteráname="stroke">#999999</CssParameter>

á á á á áá<CssParameteráname="stroke-width">0</CssParameter>

á á á áá</Stroke>

á á á</PolygonSymbolizer>á á á áá

á á á áá á á á áá<PointSymbolizer>

á áá<Graphic>

á áá<ExternalGraphic>

á á áá<OnlineResource

á á á ááxlink:type="simple"

á á á ááxlink:href="file:///C:/Subramanian/reficons/park.jpg"á/>

á á áá<Format>image/jpeg</Format>

á áá</ExternalGraphic>

á áá</Graphic>

á á á á á ááá á</PointSymbolizer>á á á á

á á á<TextSymbolizer>

á á á áá<Label>

á á á á á áá<ogc:PropertyName>NAME</ogc:PropertyName>

á á á áá</Label>

ááá á á á<LabelPlacement>

á á á á á á<PointPlacement>

á á á á á á á<AnchorPoint>

á á á á á á á á<AnchorPointX>0.5</AnchorPointX>

á á á á á á á á<AnchorPointY>1</AnchorPointY>

á á á á á á á</AnchorPoint>

á á á á á á á<Displacement>

á á á á á á á á<DisplacementX>0</DisplacementX>

á á á á á á á á<DisplacementY>-10</DisplacementY>

á á á á á á á</Displacement>

á á á á á á</PointPlacement>

á á á á á</LabelPlacement>

ááá á á á áá</TextSymbolizer>




------------------------------------------------------------------------------
WINDOWS 8 is here. 
Millions of people.  Your app in 30 days.
Visit The Windows 8 Center at Sourceforge for all your go to resources.
http://windows8center.sourceforge.net/
join-generation-app-and-make-money-coding-fast/
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users                    
                  

                                          
------------------------------------------------------------------------------
The Windows 8 Center - In partnership with Sourceforge
Your idea - your app - 30 days.
Get started!
http://windows8center.sourceforge.net/
what-html-developers-need-to-know-about-coding-windows-8-metro-style-apps/
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to