[OpenLayers-Users] Problem with layer switcher
Rahn Hanno (rahn)
rahn at zhaw.ch
Fri Oct 30 09:47:04 EDT 2009
Hello list,
I have a problem with the Layerswitcher control. Perhaps somebody can help me.
I use two different maps with different layers in one side. Now I will realise a Layerswitcher for both maps. But the layerswitcher only works for one map. The second one shows my layers but I can't switch them. The control boxes can't be activated.
Here is the code for the first switcher:
var map = new OpenLayers.Map('map',options);
var wms = new OpenLayers.Layer.WMS("Gemeinden",urlArray, {map:mapFile, layers:layerName, format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var siedlung_200 = new OpenLayers.Layer.WMS("Siedlung_200",urlArray, {map:mapFile,layers:"siedlung_200",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var Regionalkonferenzen = new OpenLayers.Layer.WMS("Regionalkonferenzen",urlArray, {map:mapFile,layers:"Regionalkonferenzen",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var Planungsregionen = new OpenLayers.Layer.WMS("Planungsregionen",urlArray, {map:mapFile,layers:"Planungsregionen",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var Verwaltungskreise = new OpenLayers.Layer.WMS("Verwaltungskreise",urlArray, {map:mapFile,layers:"Verwaltungskreise",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var zentrenstruktur = new OpenLayers.Layer.WMS("Zentrenstruktur",urlArray, {map:mapFile,layers:"zentrenstruktur",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var strassen = new OpenLayers.Layer.WMS("Strassennetz",urlArray, {map:mapFile,layers:"strassen_generalis",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var bahn = new OpenLayers.Layer.WMS("Eisenbahnnetz",urlArray, {map:mapFile,layers:"bahnen_generalis",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var gewaesser = new OpenLayers.Layer.WMS("Gewässer",urlArray, {map:mapFile,layers:"gewaesser",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var seen = new OpenLayers.Layer.WMS("Seen",urlArray, {map:mapFile,layers:"seen",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var lk_500 = new OpenLayers.Layer.WMS("LK_500",urlArray, {map:mapFile,layers:"lk_500",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var relief = new OpenLayers.Layer.WMS("Relief",urlArray, {map:mapFile,layers:"relief",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
siedlung_200.setVisibility(false);
Regionalkonferenzen.setVisibility(false);
Planungsregionen.setVisibility(false);
Verwaltungskreise.setVisibility(false);
zentrenstruktur.setVisibility(false);
strassen.setVisibility(false);
bahn.setVisibility(false);
gewaesser.setVisibility(false);
lk_500.setVisibility(false);
relief.setVisibility(false);
map.addLayers([seen,wms,strassen,bahn,gewaesser,relief,zentrenstruktur,siedlung_200,Regionalkonferenzen,Planungsregionen,Verwaltungskreise,lk_500]);
map.addControl(new OpenLayers.Control.LayerSwitcher({'div':OpenLayers.Util.getElement('mapSwitcher')}));
OpenLayers.Util.getElement('mapSwitcher').style.backgroundColor = "white";
OpenLayers.Util.getElement('mapSwitcher').style.width = "190";
The second switcher is like this:
var map3 = new OpenLayers.Map('map3',options2);
var wms3 = new OpenLayers.Layer.WMS("Gemeinden",urlArray, {map:mapFile,layers:layerName3,format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var siedlung_200_3 = new OpenLayers.Layer.WMS("Siedlung_200",urlArray, {map:mapFile,layers:"siedlung_200",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var Regionalkonferenzen3 = new OpenLayers.Layer.WMS("Regionalkonferenzen",urlArray, {map:mapFile,layers:"Regionalkonferenzen",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var Planungsregionen3 = new OpenLayers.Layer.WMS("Planungsregionen",urlArray, {map:mapFile,layers:"Planungsregionen",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var Verwaltungskreise3 = new OpenLayers.Layer.WMS("Verwaltungskreise",urlArray, {map:mapFile,layers:"Verwaltungskreise",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var zentrenstruktur3 = new OpenLayers.Layer.WMS("Zentrenstruktur",urlArray, {map:mapFile,layers:"zentrenstruktur",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var strassen3 = new OpenLayers.Layer.WMS("Strassennetz",urlArray, {map:mapFile,layers:"strassen_generalis",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var bahn3 = new OpenLayers.Layer.WMS("Eisenbahnnetz",urlArray, {map:mapFile,layers:"bahnen_generalis",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var gewaesser3 = new OpenLayers.Layer.WMS("Gewässer",urlArray, {map:mapFile,layers:"gewaesser",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var seen3 = new OpenLayers.Layer.WMS("Seen",urlArray, {map:mapFile,layers:"seen",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var lk_500_3 = new OpenLayers.Layer.WMS("LK_500",urlArray, {map:mapFile,layers:"lk_500",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
var relief3 = new OpenLayers.Layer.WMS("Relief",urlArray, {map:mapFile,layers:"relief",transparent: "true",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true, ratio:1} );
siedlung_200_3.setVisibility(false);
Regionalkonferenzen3.setVisibility(false);
Planungsregionen3.setVisibility(false);
Verwaltungskreise3.setVisibility(false);
zentrenstruktur3.setVisibility(false);
strassen3.setVisibility(false);
bahn3.setVisibility(false);
gewaesser3.setVisibility(false);
lk_500_3.setVisibility(false);
relief3.setVisibility(false);
map3.addLayers([seen3,wms3,strassen3,bahn3,gewaesser3,relief3,zentrenstruktur3,siedlung_200_3,Regionalkonferenzen3,Planungsregionen3,Verwaltungskreise3,lk_500_3]);
map3.addControl(new OpenLayers.Control.LayerSwitcher({'div':OpenLayers.Util.getElement('mapSwitcher3')}));
OpenLayers.Util.getElement('mapSwitcher').style.backgroundColor = "white";
OpenLayers.Util.getElement('mapSwitcher').style.width = "190";
Can somebody please help me? I don't know where I make the mistake. A lot of thanks for you.
Greetings
Hanno Rahn
------------------------------------------
Hanno Rahn, Dipl.-Ing. (FH) Geoinformatik
ZHAW Zürcher Hochschule für Angewandte Wissenschaften Umwelt und Natürliche Ressourcen
Fachstelle Geoinformatik
Grüental, Postfach CH-8820 Wädenswil
Tel +41 (0)58 934 5592
Fax +41 (0)58 934 5580
hanno.rahn at zhaw.ch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20091030/2c0a67ef/attachment.html
More information about the Users
mailing list