开发者

How to get list of layers from geoserver

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 do开发者_运维知识库es this?


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


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..");
        });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜