Back to Devexpress

MapControl.CalcHitInfo(Point) Method

windowsforms-devexpress-dot-xtramap-dot-mapcontrol-dot-calchitinfo-x28-system-dot-drawing-dot-point-x29.md

latest2.6 KB
Original Source

MapControl.CalcHitInfo(Point) Method

Returns information on the map elements located at the specified point.

Namespace : DevExpress.XtraMap

Assembly : DevExpress.XtraMap.v25.2.dll

NuGet Package : DevExpress.Win.Map

Declaration

csharp
public MapHitInfo CalcHitInfo(
    Point hitPoint
)
vb
Public Function CalcHitInfo(
    hitPoint As Point
) As MapHitInfo

Parameters

NameTypeDescription
hitPointPoint

The hit point, relative to the map’s top-left edge integer screen coordinates.

|

Returns

TypeDescription
MapHitInfo

The object containing information about the map elements located at the hit point.

|

Remarks

Use the CalcHitInfo method to determine which element is located at the specified hit point. For instance, this can be used when handling the map’s MouseDown event to determine which element was clicked. In such cases, pass the current mouse pointer’s coordinates as the method’s parameter.

Note

The returned MapHitInfo object does not contain the test point location in map coordinates. To obtain the location, use the MapControl.ScreenPointToCoordPoint method.

Example

csharp
mapControl1.MouseClick += OnMapControlMouseClick;
//...
private void OnMapControlMouseClick(object sender, MouseEventArgs e) {
    MapHitInfo info = mapControl1.CalcHitInfo(e.Location);
    if (info.InMapSpline) {
        gridControl1.DataSource = info.MapSpline.Points;           
    }
}
vb
mapControl1.MouseClick += OnMapControlMouseClick
'...
Private Sub OnMapControlMouseClick(ByVal sender As Object, ByVal e As MouseEventArgs)
    Dim info As MapHitInfo = mapControl1.CalcHitInfo(e.Location)
    If info.InMapSpline Then
        gridControl1.DataSource = info.MapSpline.Points
    End If
End Sub

See Also

MapControl Class

MapControl Members

DevExpress.XtraMap Namespace