⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clscoordinat.vb

📁 Get Map Coordinat by click on map
💻 VB
字号:
Imports Microsoft.VisualBasic
Imports MapInfo
Imports MapInfo.Mapping
Imports MapInfo.WebControls

Namespace MapLayer
    ''' <summary>
    ''' Mendapatkan koordinat peta
    ''' </summary>
    ''' <remarks></remarks>
    <Serializable()> Public Class ClsCoordinat

        Inherits MapInfo.WebControls.MapBaseCommand

        Public Sub New()
            MyBase.Name = "ClsCoordinat"
        End Sub
        ''' <summary>
        ''' Override the Execute method in MapBasicCommand class to not save state, because
        ''' for info tool, which does not change map state, so there is no need to save map state.
        ''' </summary>
        Public Overrides Sub Execute()

            Dim sm As StateManager = StateManager.GetStateManagerFromSession()
            If sm Is Nothing Then
                If StateManager.IsManualState() Then
                    Throw New NullReferenceException("Cannot find instance of StateManager in the ASP.NET session.")
                End If
            End If
            ParseContext()
            If Not (sm Is Nothing) Then
                PrepareStateManagerParamsDictionary(sm)
                sm.RestoreState()
            End If

            Process()
        End Sub

        Public Overrides Sub Process()

            Dim klikPoint As System.Drawing.Point() = Me.ExtractPoints(MyBase.DataString)
            Dim model As MapControlModel = MapControlModel.GetModelFromSession()
            Dim peta As Map = model.GetMapObj(MyBase.MapAlias)

            If peta Is Nothing Then Return

            model.SetMapSize(Me.MapAlias, Me.MapWidth, Me.MapHeight)

            'konversi koordinat image ke koordinat geografis
            Dim dp As MapInfo.Geometry.DPoint

            peta.DisplayTransform.FromDisplay(klikPoint(0), dp)
            Dim koordinat As String = "X: " & CStr(Math.Round(dp.x, 3)) & "&nbsp;&nbsp;&nbsp;Y: " & CStr(Math.Round(dp.y, 3))

            'MsgBox(koordinat)

            HttpContext.Current.Response.Output.Write(koordinat)
        End Sub
    End Class
End Namespace

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -