Is it possible to collapse the overlay switcher, ideally server side (otherwise in client side) ?
my point to make it server side is to collapse the overlayswitcher if there is only one dynamic overlay.
thanks for your help
Is it possible to collapse the overlay switcher, ideally server side (otherwise in client side) ?
my point to make it server side is to collapse the overlayswitcher if there is only one dynamic overlay.
thanks for your help
Hi, sebastien
Yes, you can do that on the server-side and client-side, and also it will be more easily if you choose the client-side. You just need to register “addlayer” and “removelayer” client events for map control and to check the number of layers of map control, and then if it equals one and call the minimizeControl method of LayerSwitcher control.
If you want to get it on the server-side and we don’t have the equivalent server events to support that.
If you still have other questions, please let us know.
Thanks,
Khalil
sorry i dont find any documentation on thinkgeo to do that, could you give me the source code to make that work ?
thanks for your help
Hi Sebastien,
Just as Khailil have mentioned, it will easier using client side code. There are kinds of client side function we can use to control the OverlaySwitcher. Here as following is the code about how hide and show the OverlaySwitcher.
<script language="javascript" type="text/javascript">
function CollapseOverlayerSwitcher() {
var map = Map1.GetOpenLayersMap();
var overlaySwitcher = map.getControlsByClass("OpenLayers.Control.LayerSwitcher")[0];
if (overlaySwitcher) {
// Collapse OverlaySwicther
overlaySwitcher.minimizeControl();
// Also wen can show the OverlayerSwitcher again using the code below:
// overlaySwitcher.maximizeControl();
}
}
</script>
Hope it’s helpful to you. Thanks,
Johnny
and is it possible to make that in the code behind. What i want to do is : when i have only one overlay in the overlay switcher i want to hide it.
what do you think?
thanks for your help
Sebastien,
Sorry that there isn’t built-in function on server side now, but we can hide the OverlaySwitcher using the code:
Map1.MapTools.OverlaySwitcher.Enable = false;
Thanks,
Johnny