Using LoadMapState, Layers not turning off

Apr 19, 2012 at 1:41 PM


I have the Map control and a Legend on the form.

I use LoadMapState to load a mwprj file in the Map control like:

     Legend1.Map = Map1.GetOcx
     Map1.LoadMapState("D:\GIS.mwprj", callback)
     Dim handle As Integer
     For i As Integer = 0 To Map1.NumLayers - 1
         handle = Legend1.Layers.Add(Map1.get_Shapefile(i), True)

Now when I uncheck the layer in the legend control (to make it invisible), the layer is still visible!?!?

When I add a shapefile normally it works:

     Dim sf As New MapWinGIS.Shapefile
     If sf.Open("D:\GIS.shp") Then
         Legend1.Layers.Add(sf, True)
     End If

Am I missing something?

Thank you.