change projection of map window

Jul 25, 2012 at 3:19 PM

Hi,

i have a problem to project shapefiles to another coordinate system.

I Reprojected the shape file and this seems to work. But the display in my mapwindow is not updated. Can anybody help me?

 

My code:

    Public Sub SetMapProjectionbyEPSG(ByVal EPSG As Integer)
        Dim proj As New MapWinGIS.GeoProjection
        proj.ImportFromEPSG(EPSG)

        If map.LayerCount > 0 Then
            For Each layer In map.LayerList
                Dim count As Integer
                layer.ShpObject.ReprojectInPlace(proj, count)
                layer.ShpObject.GeoProjection = proj
            Next
        Else
            MessageBox.Show("No layers available. Map projection is not yet fixed!")
        End If
    End Sub

 

Function in the class which calls the upper function:

Private Sub BtnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOk.Click
        If RBtnEPSG.Checked = True Then
            If MTbEPSG.Text = "" Then
                MessageBox.Show("Please enter an EPSG code")
            Else
                SetMapProjectionbyEPSG(CInt(MTbEPSG.Text))
                map.MyControl.Redraw()
                map.MyControl.Refresh()
                Me.Dispose()
                Me.Close()
            End If
        End If
    End Sub

Coordinator
Jul 27, 2012 at 8:28 AM

You probably need to reload the layer.
You can do this by removing the layer and add it again.

Let me know if this helps.

Paul