I have a group layer. Its purpose is to show feature layers over a base map. Those feature layers are logically grouped into categories and we provide the ability to add/remove whole categories through a menu.
The categorization is done using a dictionary
layerCategories <string [category name], List<IFeatureLayer>>
When I want to delete a category, I do something like the following
void deleteCategory( string categoryName){
foreach(var layer in layerCategories[categoryName]){
theGrouLayer.Delete(layer); // delete layer from group layer
}
layerCategories.Remove(categoryName); // remove layers (along with the category)
}
The code works, what I ask if it could be done better. I mean, are the layers disposed properly this way or should I do something explicitly?
Thanx in advance