ThinkGeo.com    |     Documentation    |     Premium Support

Clear a ShapeFileFeatureLayer

Hello,


 


I am using  a  ShapeFileFeatureLayer "worldLayer" as shown in the code below.


I have to clear the "worldLayer" after its operation are performed in function called clear_click(). How to achieve this ??


 


load()


{




            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(filename);

            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green));

            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.LineJoin = DrawingLineJoin.Round;

            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;



            LayerOverlay staticOverlay = new LayerOverlay();

            staticOverlay.Layers.Add("WorldLayer", worldLayer); 

            winformsMap1.Overlays.Add(staticOverlay);



            InMemoryFeatureLayer highlightLayer = new InMemoryFeatureLayer();

            highlightLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            highlightLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(100, GeoColor.StandardColors.DarkGreen));



            LayerOverlay highlightOverlay = new LayerOverlay();

            highlightOverlay.Layers.Add("HighlightLayer", highlightLayer);

            winformsMap1.Overlays.Add("HighlightOverlay", highlightOverlay);



            winformsMap1.CurrentExtent = new RectangleShape(-165.7421875, 80.23046875, -35.6640625, 13.08203125);

            winformsMap1.Refresh();



            worldLayer.Open();

            DataTable dataTable = worldLayer.QueryTools.ExecuteQuery("Select * from USStates Where PERIMETER > 30 Order by PERIMETER");

            worldLayer.Close();


}


 private void Result_SelectionChanged(object sender, EventArgs e)

        {

            

            FeatureLayer worldLayer = winformsMap1.FindFeatureLayer("WorldLayer");

            InMemoryFeatureLayer highlightLayer = (InMemoryFeatureLayer)winformsMap1.FindFeatureLayer("HighlightLayer");


            


          and some other operations are performed here....


          winformsMap1.Refresh(winformsMap1.Overlays["HighlightOverlay"]);

        }


 



Sneha,


If I didn't misunderstand anything, I think the following code can meet your requirement properly:



layerOverlay.Layers.Remove("WorldLayer");

You can remove the special shape file feature layer from your map according to the code above, if you want to clear all of the shape files from the map, please refer the following code:



layerOverlay.Layers.Clear();

Thanks,


Scott,



Thanks scott for the feedback. It worked out…

Sneha, 
  
 Thanks for letting us know the status. 
  
 Any more questions please feel free to let me know. 
  
 Thanks. 
  
 Yale