[OpenLayers-Dev] Getting list of layers from a mapsever + openlayers that are in a viewport extent

Tim Schaub tschaub at opengeo.org
Tue Apr 6 19:45:21 EDT 2010

Scott Stewart wrote:
> Hi,
> Using Openlayers with Mapserver (backended by a POSTGIS db), is there any
> known or prescribed way to get a list of layers that would be displayed in
> the viewport?

A WMS GetCapabilities request will return a document listing all 
available layers if you've configured your mapfile for WMS.

With a typical GetCapabilites request, you can't ask the server to limit 
what it responds with (only layers in a provided bounding box).  The 
client is forced to deal with the full capabilities doc, but you can do 
the filtering after parsing.

The OpenLayers.Format.WMSCapabilities parser can be of use in parsing 
capabilities docs.

> If it matters, we do store the extent of each layer in the mapserver map
> config file.
> The end game is to be able to build a legend for layers that are on the map.
> Any ideas?

A WMS GetLegendGraphic request will return a server generated legend.


> ------------------------------------------------------------------------
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev

Tim Schaub
OpenGeo - http://opengeo.org
Expert service straight from the developers.

More information about the Dev mailing list