Image 带有外部图形和属性规则的Geoserver SLD样式设置问题

Image 带有外部图形和属性规则的Geoserver SLD样式设置问题,image,icons,geoserver,wms,sld,Image,Icons,Geoserver,Wms,Sld,我正在为Geoserver wms层创建SLD。SLD验证无误,但图标不会显示在地图中。我使用基于属性的规则来比较字符串,以便为正确的功能显示正确的图像。这是我的代码,谢谢你的帮助 <?xml version="1.0" encoding="ISO-8859-1"?> <StyledLayerDescriptor version="1.0.0" xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescript

我正在为Geoserver wms层创建SLD。SLD验证无误,但图标不会显示在地图中。我使用基于属性的规则来比较字符串,以便为正确的功能显示正确的图像。这是我的代码,谢谢你的帮助

<?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">
<NamedLayer>
<Name>Upper Shore Image Points</Name>
<UserStyle>
  <Title>Vendor Points</Title>
  <FeatureTypeStyle>
  <Rule>
   <Name>Famers Market</Name>
    <Title>All Farmers Markets</Title>
      <ogc:Filter>
        <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
           <ogc:PropertyName>type</ogc:PropertyName>
           <ogc:Literal>farmers maket vendor</ogc:Literal>
         </ogc:PropertyIsLike>
       </ogc:Filter>
      <PointSymbolizer>
        <Graphic>
          <ExternalGraphic>
            <OnlineResource
              xlink:type="simple"
              xlink:href="Farmers Markets.jpg" />
            <Format>image/jpeg</Format>
          </ExternalGraphic>
          <Size>32</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule>
   <Rule>
   <Name>Fruit and Vegetable</Name>
    <Title>All Fruit and Vegetable</Title>
      <ogc:Filter>
        <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
           <ogc:PropertyName>type</ogc:PropertyName>
           <ogc:Literal>Fruit and Vegetable Farm</ogc:Literal>
         </ogc:PropertyIsLike>
       </ogc:Filter>
      <PointSymbolizer>
        <Graphic>
          <ExternalGraphic>
            <OnlineResource
              xlink:type="simple"
              xlink:href="Fruit and Vegetable Farms.jpg" />
            <Format>image/jpeg</Format>
          </ExternalGraphic>
          <Size>32</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule>
 <Rule>
   <Name>Horse Stable</Name>
    <Title>All Horse Stables</Title>
      <ogc:Filter>
        <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
           <ogc:PropertyName>type</ogc:PropertyName>
           <ogc:Literal>Horse Stable</ogc:Literal>
         </ogc:PropertyIsLike>
       </ogc:Filter>
      <PointSymbolizer>
        <Graphic>
          <ExternalGraphic>
            <OnlineResource
              xlink:type="simple"
              xlink:href="Horse Stable.jpg" />
            <Format>image/jpeg</Format>
          </ExternalGraphic>
          <Size>32</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule>
     <Rule>
   <Name>Wool Products</Name>
    <Title>All Wool Products</Title>
      <ogc:Filter>
        <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
           <ogc:PropertyName>type</ogc:PropertyName>
           <ogc:Literal>Wool Products</ogc:Literal>
         </ogc:PropertyIsLike>
       </ogc:Filter>
      <PointSymbolizer>
        <Graphic>
          <ExternalGraphic>
            <OnlineResource
              xlink:type="simple"
              xlink:href="Wool Products.jpg" />
            <Format>image/jpeg</Format>
          </ExternalGraphic>
          <Size>32</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule>
     <Rule>
   <Name>Restaurant</Name>
    <Title>All Restaurants</Title>
      <ogc:Filter>
        <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
           <ogc:PropertyName>type</ogc:PropertyName>
           <ogc:Literal>Restaurant</ogc:Literal>
         </ogc:PropertyIsLike>
       </ogc:Filter>
      <PointSymbolizer>
        <Graphic>
          <ExternalGraphic>
            <OnlineResource
              xlink:type="simple"
              xlink:href="Restaurant.jpg" />
            <Format>image/jpeg</Format>
          </ExternalGraphic>
          <Size>32</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule>
     <Rule>
   <Name>Coffee Roasting</Name>
    <Title>All Coffee Roasting</Title>
      <ogc:Filter>
        <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
           <ogc:PropertyName>type</ogc:PropertyName>
           <ogc:Literal>Coffee Roasting</ogc:Literal>
         </ogc:PropertyIsLike>
       </ogc:Filter>
      <PointSymbolizer>
        <Graphic>
          <ExternalGraphic>
            <OnlineResource
              xlink:type="simple"
              xlink:href="Coffee Roasting.jpg" />
            <Format>image/jpeg</Format>
          </ExternalGraphic>
          <Size>32</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule>
     <Rule>
   <Name>Charter Service</Name>
    <Title>All Charter Services</Title>
      <ogc:Filter>
        <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
           <ogc:PropertyName>type</ogc:PropertyName>
           <ogc:Literal>Charter Service</ogc:Literal>
         </ogc:PropertyIsLike>
       </ogc:Filter>
      <PointSymbolizer>
        <Graphic>
          <ExternalGraphic>
            <OnlineResource
              xlink:type="simple"
              xlink:href="Charter Service.jpg" />
            <Format>image/jpeg</Format>
          </ExternalGraphic>
          <Size>32</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule>
     <Rule>
   <Name>Apiary</Name>
    <Title>All Apiaries</Title>
      <ogc:Filter>
        <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
           <ogc:PropertyName>type</ogc:PropertyName>
           <ogc:Literal>Apiary</ogc:Literal>
         </ogc:PropertyIsLike>
       </ogc:Filter>
      <PointSymbolizer>
        <Graphic>
          <ExternalGraphic>
            <OnlineResource
              xlink:type="simple"
              xlink:href="Apiary.jpg" />
            <Format>image/jpeg</Format>
          </ExternalGraphic>
          <Size>32</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule>
     <Rule>
   <Name>Vineyard</Name>
    <Title>All Vineyards</Title>
      <ogc:Filter>
        <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
           <ogc:PropertyName>type</ogc:PropertyName>
           <ogc:Literal>Vineyard</ogc:Literal>
         </ogc:PropertyIsLike>
       </ogc:Filter>
      <PointSymbolizer>
        <Graphic>
          <ExternalGraphic>
            <OnlineResource
              xlink:type="simple"
              xlink:href="Vineyard.jpg" />
            <Format>image/jpeg</Format>
          </ExternalGraphic>
          <Size>32</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule>
     <Rule>
   <Name>Retail Seafood</Name>
    <Title>All Retail Seafood</Title>
      <ogc:Filter>
        <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
           <ogc:PropertyName>type</ogc:PropertyName>
           <ogc:Literal>Retail Seafood</ogc:Literal>
         </ogc:PropertyIsLike>
       </ogc:Filter>
      <PointSymbolizer>
        <Graphic>
          <ExternalGraphic>
            <OnlineResource
              xlink:type="simple"
              xlink:href="Retail Seafood.jpg" />
            <Format>image/jpeg</Format>
          </ExternalGraphic>
          <Size>32</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule>
     <Rule>
   <Name>Bakery</Name>
    <Title>All Bakeries</Title>
      <ogc:Filter>
        <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
           <ogc:PropertyName>type</ogc:PropertyName>
           <ogc:Literal>Bakery</ogc:Literal>
         </ogc:PropertyIsLike>
       </ogc:Filter>
      <PointSymbolizer>
        <Graphic>
          <ExternalGraphic>
            <OnlineResource
              xlink:type="simple"
              xlink:href="Bakery.jpg" />
            <Format>image/jpeg</Format>
          </ExternalGraphic>
          <Size>32</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule>
     <Rule>
       <Name>Dairy/Eggs</Name>
       <Title>All Dairy/ Eggs</Title>
      <ogc:Filter>
        <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
           <ogc:PropertyName>type</ogc:PropertyName>
          <ogc:Literal>Dairy/Eggs</ogc:Literal>
         </ogc:PropertyIsLike>
       </ogc:Filter>
      <PointSymbolizer>
        <Graphic>
          <ExternalGraphic>
            <OnlineResource
              xlink:type="simple"
              xlink:href="Dairy_Eggs.jpg" />
            <Format>image/jpeg</Format>
          </ExternalGraphic>
          <Size>32</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule>
     <Rule>
   <Name>Christmas Tree Farm</Name>
    <Title>All Christmas Tree Farms</Title>
      <ogc:Filter>
        <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
           <ogc:PropertyName>type</ogc:PropertyName>
           <ogc:Literal>Christmas Tree Farm</ogc:Literal>
         </ogc:PropertyIsLike>
       </ogc:Filter>
      <PointSymbolizer>
        <Graphic>
          <ExternalGraphic>
            <OnlineResource
              xlink:type="simple"
              xlink:href="Christmas Tree Farm.jpg" />
            <Format>image/jpeg</Format>
          </ExternalGraphic>
          <Size>32</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule>
     <Rule>
       <Name>Grains</Name>
       <Title>All Grain Farms</Title>
      <ogc:Filter>
        <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
           <ogc:PropertyName>type</ogc:PropertyName>
          <ogc:Literal>Grains</ogc:Literal>
         </ogc:PropertyIsLike>
       </ogc:Filter>
      <PointSymbolizer>
        <Graphic>
          <ExternalGraphic>
            <OnlineResource
              xlink:type="simple"
              xlink:href="Grains.jpg" />
            <Format>image/jpeg</Format>
          </ExternalGraphic>
          <Size>32</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule>
     <Rule>
   <Name>Meat Products</Name>
    <Title>All Meat Products</Title>
      <ogc:Filter>
        <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
           <ogc:PropertyName>type</ogc:PropertyName>
           <ogc:Literal>Meat Products</ogc:Literal>
         </ogc:PropertyIsLike>
       </ogc:Filter>
      <PointSymbolizer>
        <Graphic>
          <ExternalGraphic>
            <OnlineResource
              xlink:type="simple"
              xlink:href="Meat.jpg" />
            <Format>image/jpeg</Format>
          </ExternalGraphic>
          <Size>32</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule>
     <Rule>
   <Name>Nursery</Name>
    <Title>All Nurseries</Title>
      <ogc:Filter>
        <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
           <ogc:PropertyName>type</ogc:PropertyName>
           <ogc:Literal>Nursery</ogc:Literal>
         </ogc:PropertyIsLike>
       </ogc:Filter>
      <PointSymbolizer>
        <Graphic>
          <ExternalGraphic>
            <OnlineResource
              xlink:type="simple"
              xlink:href="Nursery.jpg" />
            <Format>image/jpeg</Format>
          </ExternalGraphic>
          <Size>32</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule>
     <Rule>
   <Name>Petting Zoo</Name>
    <Title>All Petting Zoos</Title>
      <ogc:Filter>
        <ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
           <ogc:PropertyName>type</ogc:PropertyName>
           <ogc:Literal>Petting Zoo</ogc:Literal>
         </ogc:PropertyIsLike>
       </ogc:Filter>
      <PointSymbolizer>
        <Graphic>
          <ExternalGraphic>
            <OnlineResource
              xlink:type="simple"
              xlink:href="Petting Zoo.jpg" />
            <Format>image/jpeg</Format>
          </ExternalGraphic>
          <Size>32</Size>
        </Graphic>
      </PointSymbolizer>
    </Rule>
  </FeatureTypeStyle>
</UserStyle>

上岸影像点
供应商点
农民市场
所有农贸市场
类型
农场主卖主
图像/jpeg
32
水果和蔬菜
所有水果和蔬菜
类型
果蔬农场
图像/jpeg
32
马厩
所有马厩
类型
马厩
图像/jpeg
32
羊毛制品
所有羊毛制品
类型
羊毛制品
图像/jpeg
32
餐厅
所有餐厅
类型
餐厅
图像/jpeg
32
咖啡烘焙
全咖啡烘焙
类型
咖啡烘焙
图像/jpeg
32
包机服务
所有包机服务
类型
包机服务
图像/jpeg
32
养蜂场
所有蜂房
类型
养蜂场
图像/jpeg
32
葡萄园
所有葡萄园
类型
葡萄园
图像/jpeg
32
零售海鲜
所有零售海鲜
类型
零售海鲜
图像/jpeg
32
面包店
所有面包店
类型
面包店
图像/jpeg
32
奶制品/鸡蛋
所有奶制品/鸡蛋
类型
奶制品/鸡蛋
图像/jpeg
32
圣诞树农场
所有圣诞树农场
类型
圣诞树农场
图像/jpeg
32
谷物
所有谷物农场
类型
谷物
图像/jpeg
32
肉制品
所有肉类产品
类型
肉制品
图像/jpeg
32
婴儿室
所有托儿所
类型
婴儿室
图像/jpeg
32
宠物动物园
所有的宠物动物园
类型
宠物动物园
图像/jpeg
32

我知道这篇文章很老了,但也许有人会从我的回答中受益

我没有成功地使用相对图像路径,所以我转而使用URL路径

将图像放入$GEOSERVER\u DATA\u DIR/styles中,并使用
http://localhost:8081/geoserver/styles/some_image.png

比如说

<ExternalGraphic>
  <OnlineResource xlink:type="simple" xlink:href="http://localhost:8081/geoserver/styles/some_image.png"/>
  <Format>image/png</Format>
</ExternalGraphic>

图像/png

回答很好,但是如果geoserver实例在端口8080上工作,您需要将8081更改为8080

您可以将图像放入样式文件夹中

非常感谢。我无法以任何其他方式访问图像。