The process to work with layers consists of two steps:
map.addLayer(layer)to add an individual layer, or
map.addLayers([layer1, layer2, ...])to add an array of layers, like in the previous example.
These two steps can actually be combined into one step (by instantiating the layer object when calling the
addLayer function—this works, but I don't recommend it as it makes it a little harder to work with the layer object). By now, we have a bit of experience instantiating objects from the WMS Layer class. Let's take a look at the code that creates our
wms_base layer object.
var wms_layer_map = new OpenLayers.Layer.WMS( 'Base layer', 'http://vmap0.tiles.osgeo.org/wms/vmap0', ...