[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
Hi,
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 =
"../"+projet+"/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities";
var map = new OpenLayers.Map('map');
for (j=2;j<x.length;j++)
{
map.addLayers([new
OpenLayers.Layer.WMS(x[j].firstChild.nodeValue,url_app_wms,{layers:x[j].firstChild.nodeValue},options)]);
}
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToMaxExtent();
/*************************/
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
background.
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.
http://localhost:8081/monde/wms?VERSION=1.3.0&REQUEST=GetMap&LAYERS=countries,cities&STYLES=&CRS=&BBOX=-75,43,-70,48&WIDTH=640&HEIGHT=480&FORMAT=image/png
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