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 am using geoserver to serve up an image pyramid basemap. I want to have all areas outside of the data extent be black (instead of white).

I have the map displayed inside of a div tag and changing the css on that tag or the container (another div) it resides in has no effect. I have checked both the geoserver and openlayers documentation, but have not seen any way to change the background color.

Any suggestions on where to continue searching? Do I need to generate a black tiles and serve them?

share|improve this question

2 Answers 2

up vote 8 down vote accepted

You can set the background color in the WMS request, using the BGCOLOR param, with a hex value. Example: &BGCOLOR=0x000000

share|improve this answer
    
Thanks! Working as expected now. –  Jay Laura Feb 14 '12 at 19:14

In the definition of the WMS layer in your OpenLayers JavaScript code, you can specify the parameter bgcolor. This will eventually add the BGCOLOR parameter to the URL to the WMS service as explained already. For example:

var osm = new OpenLayers.Layer.WMS(
    "OpenStreetMap",
    url,
    {
        width: '600',
        height: '400',
        srs: 'EPSG:3857',
        layers: 'OpenStreetMap',
        styles: '',
        format: 'image/png',
        bgcolor: '0x80BDE3'
     },
     {
        singleTile: true,
        ratio: 1,
        visibility: true,
        isBaseLayer: true
    }
);
share|improve this answer
    
Spot on and a slightly more complete answer as someone might not be totally sure where to add the parameter. Thanks! –  Jay Laura Feb 17 '12 at 0:54

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.