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

  • Do you just want to remove layers from group layer? For that, I think, your code is perferct – Emi Jan 17 '13 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.