This project has moved and is read-only. For the latest updates, please go here.


Topics: Web Controls, WinForms Controls
Sep 23, 2011 at 8:53 AM

Hii.. I'm new to SharpMap just trying to create some basic tools.

I have created a panel which consist of checkboxes. When a checkbox is clicked that respective layer should be displayed in PictureBox.
My query is:-

                        when i'm unchecking the checkbox it doesn't remove that respective layer.
                        I also want to keep the boundary of map(for example-country boundary)be is displayed all the time irrespective of all other checkbox checked or not.

Please suggest

Thanks in advance


Sep 27, 2011 at 12:35 AM


you should have a this kind of code

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged

End Sub

    Public Sub LayerVisible(ByVal layerName As String, ByVal visible As Boolean)
        Dim layer As SharpMap.Layers.ILayer = myMap.Layers(layerName)
        If visible = True Then
            layer.Enabled = True
            layer.Enabled = False
        End If
          PictureBox1.Image = myMap.GetMap() 'refresh map
    End Sub

Remenber if you use checkedlistbox instead CheckBox that the check state isn't updated before the event CheckListBox_ItemCheck but after, you have to manage this point before calling LayerVisible.

If you want to keep the boundary of the country, you must leave the country always visible and change the layer style to transparent:  myLayer.Style.Fill = Brushes.Transparent

and myLayer.Style.EnableOutline = True
        myLayer.Style.Outline = Pens.DarkRed  to have the boundary.