2

The .png's are stored here: C:\Program Files (x86)\GeoServer 2.12.1\data_dir\styles.

I have seen many different ways to incorporate a .png into Geoserver and none have worked for me. I have no idea how to proceed.

These are a few formats that I have tried:

  1. xlink:href="http://localhost:8080/geoserver/styles/Switch.png"
  2. xlink: "Switch.png"
  3. xlink:href="http://10.29.6.112:8080/geoserver/styles/Switch.png"

Does anyone have any advice or suggestions?

P.S. I am working from IP 10.29.6.112.

2 Answers 2

1

The filepath should refer to the local file on the server, so similar to

<se:OnlineResource xlink:type="simple" 
   xlink:href="file://C:/Program Files (x86)/GeoServer 2.12.1/data_dir/styles/Switch.png"/> 

If the style is linked to a workspace, I believe the relative reference is based on /geoserver_data/workspaces/workspaceName/styles/ and not on /geoserver_data/styles/

2
  • Thank you for your response. I placed the .png's in the folder you named above but unfortunately, the .png still will not display.
    – MelBuske
    Dec 5, 2017 at 2:13
  • @MelBuske what does the log say?
    – JGH
    Dec 5, 2017 at 12:12
0

My working example. Below you can find config and label for point layer.

Label Placement

  • AnchorPointX = move label left/right
  • AnchorPointY = move label top/bottom
<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" xmlns:ogc="http://www.opengis.net/ogc" version="1.1.0" xmlns:se="http://www.opengis.net/se">
  <NamedLayer>
    <se:Name>Symbol</se:Name>
    <UserStyle>
      <se:Name>Symbol</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:Name>Symbol</se:Name>
          <se:MinScaleDenominator>0</se:MinScaleDenominator>
          <se:MaxScaleDenominator>3000000</se:MaxScaleDenominator>
          <se:PointSymbolizer>
             <se:Graphic>
              <se:ExternalGraphic>
                <se:OnlineResource xlink:href="img/smile.png" xlink:type="simple"/>
                <se:Format>image/png</se:Format>
              </se:ExternalGraphic>
              <!--Plain SVG fallback, no parameters-->
              <se:ExternalGraphic>
                <se:OnlineResource xlink:href="img/smile.png" xlink:type="simple"/>
                <se:Format>image/png</se:Format>
              </se:ExternalGraphic>
              <!--Well known marker fallback-->
              <se:Mark>
                <se:WellKnownName>square</se:WellKnownName>
                <se:Fill>
                  <se:SvgParameter name="fill">#e8718d</se:SvgParameter>
                </se:Fill>
                <se:Stroke>
                  <se:SvgParameter name="stroke">#232323</se:SvgParameter>
                  <se:SvgParameter name="stroke-width">0.5</se:SvgParameter>
                </se:Stroke>
              </se:Mark>
              <se:Size>21</se:Size>
            </se:Graphic>
          </se:PointSymbolizer>
        </se:Rule>
        <se:Rule>
          <se:TextSymbolizer>
            <se:Label>
              <ogc:PropertyName>label_column</ogc:PropertyName>
            </se:Label>
            <se:Font>
              <se:SvgParameter name="font-family">Arial</se:SvgParameter>
              <se:SvgParameter name="font-size">14</se:SvgParameter>
              <se:SvgParameter name="font-weight">bold</se:SvgParameter>
            </se:Font>
            <se:LabelPlacement>
              <se:PointPlacement>
                <se:AnchorPoint>
                  <se:AnchorPointX>0.5</se:AnchorPointX>
                  <se:AnchorPointY>-0.9</se:AnchorPointY>
                </se:AnchorPoint>
              </se:PointPlacement>
            </se:LabelPlacement>
            <se:Halo>
              <se:Radius>2</se:Radius>
              <se:Fill>
                <se:SvgParameter name="fill">#fafafa</se:SvgParameter>
              </se:Fill>
            </se:Halo>
            <se:Fill>
              <se:SvgParameter name="fill">#006e3c</se:SvgParameter>
            </se:Fill>
          </se:TextSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.