ThinkGeo.com    |     Documentation    |     Premium Support

Unloading a map

Is is possible unloading the layers after loading it in WinformMap?



Manas, 
  
 Of course it is possible to unload layers after loading it in WinformsMap. Two solutions are optional. One is setting the target Layer IsVisible property to false, the other is removing the target layers from the overlay. Both of them need to refresh the MapControl which the overlay should be passed in. 
  
 Any more questions just feel free to let me know. 
  
 Thanks. 
  
 Yale 


To be a little bit more specific code wise, I show you an example of how to remove a layer after it has been added to a LayerOverlay:


First, the countries shapefile is added to the map:



 winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);

            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"..\..\Data\Countries02.shp");
            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay worldOverlay = new LayerOverlay();
            worldOverlay.Layers.Add("WorldLayer", worldLayer);
            winformsMap1.Overlays.Add("WorldOverlay", worldOverlay);

            winformsMap1.Refresh();

            //Then removes the shapefile

            worldOverlay.Layers.Remove("WorldLayer");
            winformsMap1.Refresh();