To query the actual layer visibility, use the MgLayer::IsVisible() method. There is no method to set actual visibility because it depends on other visibility settings.
To query the visibility setting for a layer, use the MgLayer::GetVisible() method. To change the visibility setting for a layer, use the MgLayer::SetVisible() method.
To query the visibility setting for a layer group, use the MgGroup::GetVisible() method. To change the visibility setting for a layer group, use the MgGroup::SetVisible() method.
To change the layer visibility for a given view scale, modify the layer resource and save it back to the repository. See Modifying Maps and Layers for details.
The following example turns on the visibility for the Roads layer.
$layers = $map->GetLayers();
$roadsLayer = $layers->GetItem('Roads');
$roadsLayer->SetVisible(True);
Changing the visibility will have no effect until the map is saved and refreshed.