12

Is it possible to get a list of all the layers served by geoserver? I.e. is there some specific url request to send that does this?

filinep
  • 529
  • 2
  • 11
  • 17
  • here is a WMS parser/beautifier (I'm new to this and it helped) https://geoportal.bayern.de/getcapabilities/;jsessionid=451FDFA90393C2C3F073949CF7715707?wicket-crypt=g-lD2bjSH6E – Ivan Ferrer Villa Mar 31 '17 at 09:04

2 Answers2

9

The capabilities links on the geoserver home page each list layers served via various services:

  • the WMS capabilities lists layers that support requests for tiled images
  • the WFS capabilities lists layers that support requests for vector data
  • the WCS capabilities lists layers that support raster queries

A sample WMS request would look like this:

http://demo.opengeo.org/geoserver/wms?request=GetCapabilities&service=WMS&version=1.0.0

David Winslow
  • 8,472
  • 1
  • 31
  • 27
  • 1
    How can I get capability of only one layer? Can I get capability of layer by passing layername? – prem30488 Sep 29 '14 at 07:26
  • No. The only thing you can do is using workspaces to split layers into multiple groups and then perform the getcapability at the workspace level, check this link http://docs.geoserver.org/latest/en/user/services/virtual-services.html. As an alternative you can make calls to the REST administrative interface of GeoServer but then you need to be an admin. – simogeo Oct 25 '14 at 09:32
4

So just for completeness, here's an example of how to get a list/array of layers:

        var formatter = new OpenLayers.Format.WMSCapabilities();
        var endpoint = "path/to/wms/endpoint";
        var layers = [];

        // async call to geoserver (I'm using angular)
        $http.get(endpoint + 'request=GetCapabilities').

        success(function(data, status, headers, config) {

            // use the tool to parse the data
            var response = (formatter.read(data));

            // this object contains all the GetCapabilities data
            var capability = response.capability;

            // I want a list of names to use in my queries
            for(var i = 0; i < capability.layers.length; i ++){
                layers.push(capability.layers[i].name);
            }
        }).

        error(function(data, status, headers, config) {
            alert("terrible error logging..");
        });
danwild
  • 1,886
  • 1
  • 26
  • 31