Updated code snippet on toggling of layer visibility