ArcObjects: Get the map coordinates of a map click event

Platform:ArcObjects
Task:Get the map coordinates of a map click event
Discussion:
You need to get the map coordinates of a click event on a map. Drop the following into your Addin tool.
Example:
    Protected Overrides Sub OnMouseUp(ByVal arg As MouseEventArgs)
        Try
            '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