admin管理员组

文章数量:1356371

We'd like to have two different styles for a given layer group and to be able to select styles using styles=STYLE_NAME in the URL. We found that it's doable by adding alternative layer group styles using Geoserver's UI like so:

First hit "Add new", then "Add Layer", then click on each layer and assign its alternative style and you're good. Everything works when we pass styles param in the group's URL.

Fine, now how to do that via API?

If I GET such a layer group I can see info about `layerGroupsStyles":

However, if I send a POST request with the following XML

<layerGroup>
    <name>my new group</name>
    <layers><layer><name>a new layer</name></layer></layers>
    <styles>
        <style>line</style>
    </styles>
    <layerGroupStyles>
        <LayerGroupStyle>
            <name>cockpit</name>
            <layers><layer><name>a new layer</name></layer></layers>
            <styles>
                <style>my_line_style</style>
            </styles>                
        </LayerGroupStyle>
    </layerGroupStyles>
</layerGroup>

then I get this error:

Unexpected item null whose type is not among: [interface .geoserver.catalog.LayerInfo, interface .geoserver.catalog.LayerGroupInfo]

Swagger does not help as there is no mention of layerGroupsStyles at all.

Any help is much appreciated as I can't, for the life of me, understand how and where to read about Geoserver's API.

Thanks!

本文标签: geoserverHow can I add a second layerGroup style using rest APIStack Overflow