ArcObjects: Get the map coordinates of a map click event

Task:Get the map coordinates of a map click event
You need to get the map coordinates of a click event on a map. Drop the following into your Addin tool.
    Protected Overrides Sub OnMouseUp(ByVal arg As MouseEventArgs)
            'create a point to hold the clicked point's screen coordinates
            Dim pt As IPoint = New Point
            pt.PutCoords(arg.Location.X, arg.Location.Y)

            'make another point to hold the real world clicked coordinates
            Dim MyPoint As IPoint = GetMapCoordinatesFromScreenCoordinates(pt, My.ArcMap.Document.ActiveView.FocusMap)
            Dim Y As Double = MyPoint.Y
            Dim X As Double = MyPoint.X

        Catch ex As Exception
            MsgBox("2 " & ex.Message)
        End Try

    End Sub
Back to Index