Original User: rwelikalWell, you can make a TOOL or you can make a command.. a TOOL will initiate the code when you CLICK the map.I would draw a point on click using the ESRI snippet. Public Sub DrawPoint(ByVal activeView As ESRI.ArcGIS.Carto.IActiveView, ByVal x As System.Int32, ByVal y As System.Int32) If activeView Is Nothing Then
Return
End If
Dim screenDisplay As ESRI.ArcGIS.Display.IScreenDisplay = activeView.ScreenDisplay
' Constant
screenDisplay.StartDrawing(screenDisplay.hDC, CShort(ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache))
Dim simpleMarkerSymbol As ESRI.ArcGIS.Display.ISimpleMarkerSymbol = New ESRI.ArcGIS.Display.SimpleMarkerSymbolClass
Dim symbol As ESRI.ArcGIS.Display.ISymbol = TryCast(simpleMarkerSymbol, ESRI.ArcGIS.Display.ISymbol) ' Dynamic Cast
screenDisplay.SetSymbol(symbol)
Dim displayTransformation As ESRI.ArcGIS.Display.IDisplayTransformation = screenDisplay.DisplayTransformation
' X and Y are in device coordinates
Dim point As ESRI.ArcGIS.Geometry.IPoint = displayTransformation.ToMapPoint(x, y)
screenDisplay.DrawPoint(point)
screenDisplay.FinishDrawing()
End Sub
Then I would use another snippet and use that point to get the click location: Public Function GetMapCoordinatesFromScreenCoordinates(ByVal screenPoint As ESRI.ArcGIS.Geometry.IPoint, ByVal activeView As ESRI.ArcGIS.Carto.IActiveView) As ESRI.ArcGIS.Geometry.IPoint
If screenPoint Is Nothing OrElse screenPoint.IsEmpty OrElse activeView Is Nothing Then
Return Nothing
End If
Dim screenDisplay As ESRI.ArcGIS.Display.IScreenDisplay = activeView.ScreenDisplay
Dim displayTransformation As ESRI.ArcGIS.Display.IDisplayTransformation = screenDisplay.DisplayTransformation
Return displayTransformation.ToMapPoint(CInt(screenPoint.X), CInt(screenPoint.Y))
End Function
Hope that helps.