Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在xml文件(在geoserver中)中更改svg图像的颜色?是否可以在geoserver中更改?_Xml_Svg_Geoserver - Fatal编程技术网

如何在xml文件(在geoserver中)中更改svg图像的颜色?是否可以在geoserver中更改?

如何在xml文件(在geoserver中)中更改svg图像的颜色?是否可以在geoserver中更改?,xml,svg,geoserver,Xml,Svg,Geoserver,这是我的代码。我想更改svg图像本身的颜色。即使我更改了颜色代码,它也不起作用。我得到的是黑白色。我的代码中有什么错误 <se:PointSymbolizer> <se:Graphic> <!--Parametric SVG--> <se:ExternalGraphic> <se:OnlineResource xlink:href="ForServer/DRY.svg?fill=%23e01987&amp;fill-opac

这是我的代码。我想更改svg图像本身的颜色。即使我更改了颜色代码,它也不起作用。我得到的是黑白色。我的代码中有什么错误

<se:PointSymbolizer>
<se:Graphic>
<!--Parametric SVG-->
<se:ExternalGraphic>
<se:OnlineResource xlink:href="ForServer/DRY.svg?fill=%23e01987&amp;fill-opacity=1&amp;outline=%23e01987&amp;outline-opacity=1&amp;outline-width=0" xlink:type="simple"/>
<se:Format>image/svg+xml</se:Format>
</se:ExternalGraphic>
<!--Plain SVG fallback, no parameters-->
<se:ExternalGraphic>
<se:OnlineResource xlink:href="ForServer/DRY.svg" xlink:type="simple"/>
<se:Format>image/svg+xml</se:Format>
</se:ExternalGraphic>
<!--Well known marker fallback-->
<se:Mark>
<se:WellKnownName>square</se:WellKnownName>
<se:Fill>
<se:SvgParameter name="fill">#e01987</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#e01987</se:SvgParameter>
<se:SvgParameter name="stroke-width">0.5</se:SvgParameter>
</se:Stroke>
</se:Mark>
<se:Size>11</se:Size>
</se:Graphic>
</se:PointSymbolizer>

image/svg+xml
image/svg+xml
广场
#e01987
#e01987
0.5
11
您可以尝试以下方法:-

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor
  version="1.0.0"
  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"
  xmlns:gml="http://www.opengis.net/gml"
  xsi:schemaLocation="http://www.opengis.net/sld
    http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd
">
  <NamedLayer>
    <Name>redflag</Name>
        <UserStyle>
        <Name>burg</Name>
        <Title>A small red flag</Title>
        <Abstract>A sample of how to use an SVG based symbolizer
        </Abstract>
      <FeatureTypeStyle>
       <Rule>
          <PointSymbolizer>
              <Graphic>
                <ExternalGraphic>
                    <OnlineResource xlink:type="simple" xlink:href="burg02.svg" />
                    <Format>image/svg+xml</Format>
                </ExternalGraphic>
                <Size>
                 <ogc:Literal>30</ogc:Literal>
                </Size>
            </Graphic>
         </PointSymbolizer>
        <PolygonSymbolizer>
          <Fill>
            <CssParameter name="fill">#1eff00</CssParameter> <CssParameter name="fill-opacity">0.6</CssParameter>
          </Fill>
          <Stroke>
            <CssParameter name="stroke">#000000</CssParameter> <CssParameter name="stroke-width">0.5</CssParameter>
          </Stroke>
        </PolygonSymbolizer>
      </Rule>
     </FeatureTypeStyle>
    </UserStyle>
    </NamedLayer>
</StyledLayerDescriptor>

红旗
伯格
小红旗
如何使用基于SVG的符号器的示例
image/svg+xml
30
#1eff00 0.6
#000000 0.5

如果您遇到任何问题,请告诉我,GeoServer(AFAIK)不支持通过SLD文件对SVG符号进行着色,它将始终是SVG中设置的颜色。

我将SVG转换为png并提供.png图像,而不是以.SVG的形式提供图像,这非常有效

可以使用。我制作了一张只有黑色的svg图片,用作alpha遮罩。然后我做了一个比图片更大的正方形标记来应用颜色

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0" 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" xmlns:gml="http://www.opengis.net/gml" 
                       xsi:schemaLocation="http://www.opengis.net/sld">
  <NamedLayer>
    <UserStyle>
      <FeatureTypeStyle>
        <Rule>
          <PointSymbolizer>
            <Graphic>
              <ExternalGraphic>
                <OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="YOUR_SVG_FILE.svg"/>
                <Format>image/svg+xml</Format>
              </ExternalGraphic>
              <Size>45</Size>
            </Graphic>
            <VendorOption name="composite-base">true</VendorOption>
          </PointSymbolizer>
          <PointSymbolizer>
            <Graphic>
              <Mark>
                <Fill>
                  <CssParameter name="fill">#1e9e1e</CssParameter>
                  <CssParameter name="fill-opacity">1</CssParameter>
                </Fill>
              </Mark>
              <Size>50</Size>
            </Graphic>
            <VendorOption name="composite">source-in</VendorOption>
          </PointSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

image/svg+xml
45
真的
#1e9e1e
1.
50
来源于

另请参见

您可能会从中得到更好的回复。也许您可以使用作文:好的,谢谢您的回复