Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm running a map with lots of different wms layers published by geoserver. Some of them are queryable, some of them are not. How can I tell that with openlayers api? I'm requesting getfeatureinfo and I need to request only the queryable layers, layers with queryable param set to false always return "Layer is not queryable" when requested - and that's what I want to hide from users. I looked into OpenLayers.Map.layers and found no "queryable" property.

UPDATE (to the first commnent): This works fine as long as I use it with localhost:8080/geoserver/wms?service=wms&version=1.1.1&request=GetCapabilities. When I tried to get capabilities from, i got empty array of layers as a result. I'm trying it with the following code:

function getCapabilities(offline) {
    var url = '';
    if (offline) {
        url = 'localhost:8080/geoserver/wms?service=wms&version=1.1.1&request=GetCapabilities';
    else {
        url = ''
    var layers = []
        ,request = OpenLayers.Request.GET({
            url: url
            ,success: function(response) {
                var format = new OpenLayers.Format.XML()
                    ,xml =
                    ,text = format.write(xml)
                    ,CAPformat = new OpenLayers.Format.WMSCapabilities()
                    ,cap =;
                    if (cap.capability) {
                        for (var len = cap.capability.layers.length-1; len >= 0; len -= 1) {
                            if (cap.capability.layers[len].queryable) {
    return layers; //ARRAY
share|improve this question

1 Answer 1

The "queriable" information is contained in the WMS capabilities document, the one that gets returned when you hit http://host:port/geoserver/ows?request=GetCapabiliites&service=WMS

OpenLayers has this class to parse it:

share|improve this answer
Hi, this works fine as long as I use it with localhost:8080/geoserver/…. When I tried to get capabilities from…, i got empty array of layers as a result. –  Michal Zimmermann Aug 28 '12 at 12:02
You need a proxy to perform ajax calls outside the domain of your page Same origin policy - wikipedia. –  Tommaso Sep 13 '12 at 21:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.