Take the 2-minute tour ×
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 might be thinking about this all wrong, but right now I'm using Mapnik's OGC Server, and using that WMS with OpenLayers. How would I group multiple layers (say country, water, state borders) into one layer, so that all of those combined show up as a Base Layer in OpenLayers? I'm trying to do this through the Python API.

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

The idea of WMS is that you can request multiple layers (from OpenLayers) and the OGCServer will combine them into one image before returning the image.

But the trick here is that the WMS spec requires a style for each layer, so this will likely lead to an error being thrown by the OGCServer:

var wms = new OpenLayers.Layer.WMS("Mapnik WMS","http://localhost:8000?", 
                {layers: ['one','two','three'], styles:[''],format:'image/png'}, 
                { isBaseLayer: true } );

Because you need to do: styles:['','',''].

Or you can use a trick of requesting all layers in the mapfile which avoids having to specify an equal number of real or empty styles:

var wms = new OpenLayers.Layer.WMS("Mapnik WMS","http://localhost:8000?", 
                {layers: ['__all__'], styles:[''],format:'image/png'}, 
                { isBaseLayer: true } );
share|improve this answer
    
or you can leave the styles parameter out completely and the default styles will be used. –  iant Jan 22 '11 at 18:56
add comment

Your Answer

 
discard

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.