Handling Lots of Layers
If you need to create a map with lots of layers (even hundreds of layers), you'll want an easy way for the user to be able to turn the layers on and off.
Hierachical Layers
CanvasMap manages all items, including layers, in a hierarchy from the top (the MainContainer) down to each individual item. The list of layers that appears in the default map layout will show all the layers (objects derived from CMLayer) in a list. If you add layers to another layer, they will appear indented below the parent layer. You need to use "AddChild()" instead of "AddLayer()" because AddLayer() is only in the CMMainContainer class.
var TheYear=StreamBedYears[i]; // create the parent layer var ParentLayer=new CMLayer(); // create the parent layer TheMainContainer.AddLayer(ParentLayer); // add the parent to the MainContainer ParentLayer.SetSetting("Status",CMSTATUS_HIDDEN); // you can hide the parent layer to start to make drawing faster // Now add other layers to the parent layer var TheChildLayer=new CMLayerDataset(); TheChildLayer.SetSetting("Dataset","URL","TestLayer.js"); ParentLayer.AddChild(TheChildLayer);