Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
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 posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.