HOW TO
There is no tool that returns the coordinates of a specific location on a map by a mouse click. ArcObjects SDK for the Microsoft .NET Framework can be used to extend the functionality of ArcMap, wherein a new toolbar is created to return the precise coordinate on a map using the Extending ArcObjects functionality, and by modifying the OnMouseDown event.
This article provides steps to capture map coordinates with a mouse click in ArcMap using ArcObjects SDK for the Microsoft .NET Framework.
Public Sub New() 'TODO: Define your toolbar here by adding items AddItem("<Project_Name>.GetCoordinate") End Sub
Note: To change the name of the toolbar to be displayed in ArcMap, edit the Public Overrides ReadOnly Property Caption() method as follows: Public Overrides ReadOnly Property Caption() As String Get 'TODO: Replace bar caption Return "<Toolbar_Name>" End Get End Property
Public Overrides Sub OnMouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Integer, ByVal Y As Integer) Dim pMxDoc As IMxDocument = m_application.Document Dim pPoint As IPoint = pMxDoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y) MsgBox("Map X: " & pPoint.X & vbCrLf & "Map Y: " & pPoint.Y) End Sub
Note: In some cases, the IPoint variable requires the reference to the Esri.ArcGIS.Geometry library. To add the reference, right-click Reference in the Solution Explorer pane, and click Add Reference. Search for Esri.ArcGIS.Geometry and check the checkbox.
Article ID: 000024388
Get help from ArcGIS experts
Download the Esri Support App