[OpenLayers-Dev] WMS: How can I have many layers on my map?

Kevin Emamirad keyone at gmail.com
Thu May 24 14:35:31 EDT 2007


I've got two WMS layers on my world map: "countries" and "cities"

My openlayers application find by himself available layers by parsing
the XML result of the WMS's GetCapabilities request.
Available at http://localhost:8081/monde/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities

Here is how I add my layers:


var options = {maxResolution: 'auto', numZoomLevels: 20, format:
"image/png", VERSION: "1.3"};

var projet = "monde";

var url_app_wms = "../"+projet+"/wms";

var xml_getcapabilities =

var map = new OpenLayers.Map('map');

for (j=2;j<x.length;j++)

map.addControl(new OpenLayers.Control.LayerSwitcher());


This works well on OpenLayers. But when I choose "cities". I don't see
"countries" layout. So I have a map with cities points on a white
I've also tried to use Overlays, with transparent = true argument. But
the only difference is that I have a black background.

But, when I'm doing the GetMap request by hand on my browser, this works.


with &LAYERS=countries,cities i've got both layers on my map.
with &LAYERS=countries , i've got only countries and i can also have
only cities with &LAYERS=cities

So what do you suggest me .

Thanks a lot,

Kevin Emamirad

More information about the Dev mailing list