I have three to four layers (shapefile data) in GeoServer, and I have to have all of them to make a map of a city. However, so far I can only create a map with only one layer by writing

map = new OpenLayers.Map('map');
var build_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
                "http://localhost:8090/geoserver/wms/wsNYCRoad", {layers: 'building'}

If I add more layers by writing

var population_wms=...
var road_wms =...

then I can choose only one of these layers (in layer switcher) to be displayed in the browser.

How could I solve this problem? Do I have to set one of the layer as the base map and add other layers by using var vector? Then how can I convert those layers to .json file?

1 Answer 1


By default a WMS layer is considered to be an opaque base layer in OpenLayers. This means you can only see one at a time, to change this set isBaselayer: false

So for example:

  var build_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
            "http://localhost:8090/geoserver/wms/wsNYCRoad", {layers: 'building'}
            {isBaselayer: false, transparent: true});

However you will need at least one baselayer to be set or the map will not be initialised properly.

Actually that's not completely true but it's close enough for this question


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.