Hello sumeth,
Thanks for your post, we have overlay switcher instead of layer switcher because overlay is the smallest unit of imaging while layer is not. In another world, an overlay is an image passing to Client from Server, so on client side you can easily show/hide an overlay. Layer is a Server side concept, it’s more related with data and one or more layer will be drawn on one overlay, that is to say if you want to hide a layer, you need to redraw the overlay containing that very layer on server side and pass it back to client. That’s why we don’t have the LayerSwitcher.
If you mean you want to customize the OverlaySwitcher, here are two important JavaScript functions provided by OpenLayers.
One is Map.setBaseLayer(layer) which is to switch between base overlays; you can find the reference at:
dev.openlayers.org/releases/OpenLay...tBaseLayer
While another one is Layer.display(isVisible) which is to set a dynamic overlay’s visibility; you can find the reference at:
dev.openlayers.org/releases/OpenLay...er.display
The attached file is a sample for you to implement the OverlaySwitcher, please feel free to change it.
Or if you only think the OverlaySwitcher's skin is acceptable, and only want to change some position, here is the code how to do that:
function OnMapCreated(map) {
var overlaySwitcher = map.getControlsByClass("OpenLayers.Control.LayerSwitcher")[0];
// Set the position of OverlaySwitcher
overlaySwitcher.div.style.position = "fixed";
overlaySwitcher.div.style.right = "200px";
overlaySwitcher.div.style.top = "200px";
overlaySwitcher.layersDiv.style.paddingRight = "0px";
// Set the forground color for base layer
overlaySwitcher.baseLbl.style.color = "red";
overlaySwitcher.baseLbl.style.fontWeight = "bolder";
overlaySwitcher.baseLayersDiv.style.color = "blue";
// Set the forground color for none base layers
overlaySwitcher.dataLbl.style.color = "yellow";
overlaySwitcher.dataLbl.style.fontWeight = "bold";
overlaySwitcher.dataLayersDiv.style.color = "black";
}
And for the second question, you can see the attached file for details.
Please feel free to let us know if you meet any questions.
Regards,
Gary
CustomizeOverlaySwitcher.zip (3.07 KB)
ChangeTheStyleOfPanZoomBar.txt (3.58 KB)