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

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
up vote 9 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(
        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


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.