Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to get the all the layers present in a store in geoserver?

My JS file contains code for each layer present in a store. So when I publish a new layer in geoserver I have to manually include the code of the new layer in JS. But what I want is to put a for loop in JS with the layer names present in a store, like

for(i<=all layers present in store)                 
   var wmslayer2 = new OpenLayers.Layer.WMS("Layer2","http://localhost:8080/geoserver/wms", 
   {'layers': '**cite:layer[i]**', 'format':'image/png', 'transparent':'true'},
   {'opacity': 1.0, 'isBaseLayer': false, 'visibility': true}); 
share|improve this question
up vote 7 down vote accepted

The restconfig api allows you to do this:

You can request data be sent back in JSON as well which is handy from javascript code. The WMS caps has the same info but it is a huge xml document... so expensive to parse on the client side.

share|improve this answer
can you plz tell me how to request the data in any format?? i mean is it through a url or any command to be given or by a php/html file or etc??? I mean I dont know how to execute those operations specified in ur link – Vikash Talanki Jun 14 '11 at 22:02

The answer to the GetCapabilities request contains a list of all layers offered by the server. But it's probably easier to create a layer group in Geoserver that simply contains all layers. Then you only have to request that group.

share|improve this answer
But layer group contains all the layers which are shown as a single layer on map. I mean my layer switcher has only a single overlay at that time, Is it not??? – Vikash Talanki Jun 13 '11 at 15:10

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.