I have a OpenLayers map that displays a few WMS layers on top of an Open Street Map base layer. I'm would like the county boundary WMS layer to display automatically along with the base layer when the map loads.
var map;
function initMap() {
var osmlayer;
var point;
var dlr_county_boundaries_wms;
var dlr_libraries_wms;
var info;
//create new map object
map = new OpenLayers.Map("mymap");
//create new OSM base layer
osmlayer = new OpenLayers.Layer.OSM("Open Street Map");
//create WMS layers
dlr_county_boundaries_wms = new OpenLayers.Layer.WMS("DLR County Boundary (WMS)", "http://localhost:8080/geoserver/egm715/wms",
{
layers: "egm715:DLR_County_Boundary",
transparent: true
}, {
projection: "EPSG:3857",
opacity: 0.5,
visibility: false
}
);
// DLR Libraries Layer
dlr_libraries_wms = new OpenLayers.Layer.WMS("DLR Libraries (WMS)", "http://localhost:8080/geoserver/egm715/wms",
{
layers: "egm715:DLR_Libraries",
transparent: true
}, {
projection: "EPSG:3857",
opacity: 0.5,
visibility: false
}
);
//add layers to the map
map.addLayers([osmlayer, dlr_county_boundaries_wms, dlr_libraries_wms]);
//add LayerSwitcher control object
var custom_layerswitcher= new OpenLayers.Control.LayerSwitcher();
map.addControl(custom_layerswitcher);
// change Labels of Base- and Overlay-Section
custom_layerswitcher.dataLbl.innerHTML="DLR Layers";
custom_layerswitcher.baseLbl.innerHTML="Basiskarten";
// define point as a new LonLat object and transfom
point = new OpenLayers.LonLat(-6.1832, 53.2560);
point.transform("EPSG:4326", "EPSG:900913");
//centre the map and set zoom level
map.setCenter(point, 11.7);
}