是否可以获取geoserver服务的所有图层的列表?即是否有一些特定的网址请求要发送?
答案 0 :(得分:9)
地理服务器主页上的功能链接每个列出通过各种服务提供的层:
示例WMS请求如下所示:
http://demo.opengeo.org/geoserver/wms?request=GetCapabilities&service=WMS&version=1.0.0
答案 1 :(得分:4)
所以只是为了完整性,以下是如何获取图层列表/数组的示例:
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..");
});