My VB.Net MapSuite 5.5 application uses the following code to catch a right-click event on a MapSuite map and then determines if the user right-clicked on a user-drawn shape. Map1_Click() catches the click event and IsInsideShape() determines if the point clicked is inside a user-drawn circle, rectangle, polygon, etc. This code works well - but I need to catch if a user clicks on a user-drawn line or point, which doesn't work. What code can I use to add in here and also catch if a user clicks a line or point?
'check for right-click on a map object
Private Sub Map1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Map1.ClickDim mouseEventArgs As MouseEventArgs = CType(e, MouseEventArgs)'check for right-click on the map
If mouseEventArgs.Button = Windows.Forms.MouseButtons.Right Then
'calculate the point we right-clicked on the map
_selectedShape = IsInsideShapeClick(clickedLocation)
Dim clickedLocation As PointShape = ExtentHelper.ToWorldCoordinate(Map1.CurrentExtent, mouseEventArgs.X, mouseEventArgs.Y, Map1.Width, Map1.Height)'see if point is inside a user-drawn shape
If _selectedShape IsNot Nothing Then
contextMenuShapes.Show(mouseEventArgs.X, mouseEventArgs.Y)
End If
End If
End Sub
Private Function IsInsideShapeClick(ByVal clickLocation As PointShape) As DrawnShapesClass
'This function will determine if a given point is inside a shape
Dim selectedShape As DrawnShapesClass = Nothing
Dim drawnFeaturesLayer As MapShapeFeatureLayer = DirectCast(Map1.FindFeatureLayer(Name_ShapeFeatureLayer), MapShapeFeatureLayer)Dim i As Integer = 0'loop through each shape to see if any contain the clickLocation point
For Each mapShape As ExtendedMapShape In drawnFeaturesLayer.MapShapesIf clickLocation.Intersects(mapShape.Feature) Then
selectedShape = shapeArray(i)
End If
i = i + 1
Next
Return selectedShapeEnd Function