ThinkGeo.com    |     Documentation    |     Premium Support

How to Delete inMemoryFeatureLayer?

hi


I am plotting lines using multiple coordinates in an array. after i plot successfully i wanted to delete whole "inMemoryFeatureLayer" from the map and wanted to redraw lines using different coordinates.i just learnt how to delete feature from Inmemory layer or editing features. but how i can delete the InMemoryFeatureLayer or Overlays wanted to know ?.below is the code the way i m plotting line using multiple coordinates. 


dim i as integer                                                                                                                                                                                                               


       For i = 0 To rows

            LineShape.Vertices.Add(New Vertex(stlon(i), stlat(i)))

        Next


        Dim inMemoryFeatureLayer As New InMemoryFeatureLayer()

        inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.OuterPen = New GeoPen(GeoColor.FromArgb(200, GeoColor.StandardColors.Red), 5)

        inMemoryFeatureLayer.InternalFeatures.Add("Line", New Feature(LineShape))

        inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20


        Dim lineOverlay As New LayerOverlay()

        lineOverlay.Layers.Add("Line_imfl", inMemoryFeatureLayer)

        winformsMap1.Overlays.Add(lineOverlay)

 


Regards,


Zeeshan


 



 


ZEESHAN,
 
You’d better add a key to each layer/Overlay, so you can delete them easily. Just like the following code, "Line_imfl" isthe key of inMemoryFeatureLayer,
"overlay" is the key of lineOverlay.
 
Dim lineOverlay As New LayerOverlay()
            lineOverlay.Layers.Add("Line_imfl", inMemoryFeatureLayer)
            WinformsMap1.Overlays.Add("overlay", lineOverlay)
 
Here is the code you want.
 
lineOverlay.Layers.Remove("Line_imfl")    'remove inMemoryFeatureLayer from lineOverlay
            WinformsMap1.Overlays.Remove("overlay")   'remove lineOverlay from WinformsMap
 
Thanks,
James