## Draw Circles around Selected Points

This example illustrates how to select the points from a shapefile and then distinguish these points by drawing spatially referenced circles around them. This takes advantage of the fact that the radii of these circles are a certain pixel radius, so that as you zoom in or out, the selection circles will remain the same size.

'This sub responds to a command is called by a button or menu to start selecting Private Sub SelectMode() AxMap1.CursorMode = MapWinGIS.tkCursorMode.cmSelection AxMap1.SendMouseDown = True AxMap1.SendSelectBoxFinal = True End Sub Private Sub AxMap1_MouseDownEvent(ByVal sender As System.Object, ByVal e As AxMapWinGIS._DMapEvents_MouseDownEvent) Handles AxMap1.MouseDownEvent Dim Shapes() As Integer Dim ex As New MapWinGIS.Extents Dim Result As Boolean Dim x1, y1, x2, y2 As Double Dim PixelBuffer As Integer If AxMap1.CursorMode = MapWinGIS.tkCursorMode.cmSelection Then 'For point or line layers set up a rectangular extent of a 10x10 pixel grid PixelBuffer = 5 'For selecting exact polygons, use PixelBuffer = 0. AxMap1.PixelToProj(e.x - PixelBuffer, e.y + PixelBuffer, x1, y1) AxMap1.PixelToProj(e.x + PixelBuffer, e.y - PixelBuffer, x2, y2) ex.SetBounds(x1, y1, 0, x2, y2, 0) Result = shpLayers(SelectedLayer).SelectShapes(ex, 0, MapWinGIS.SelectMode.INTERSECTION, Shapes) Select_Shapes(Shapes) AxMap1.SendSelectBoxFinal = True End If End Sub 'SelectedLayer is the integer handle specifying the currently selected layer 'shpLayers() is an array of Shapefile objects storing all the current layers 'tvSelection is a treeview that shows information about selected shapes 'SelectBoxesLayer is an integer value storing the handle to the drawing layer Private Sub Select_Shapes(ByVal Shapes() As Integer) Dim I As Integer Dim nd As TreeNode If SelectBoxesLayer > -1 Then AxMap1.ClearDrawing(SelectBoxesLayer) For I = 0 To Shapes.GetUpperBound(0) nd = tvSelection.Nodes.Add("Well ID: " & shpLayers(SelectedLayer).CellValue(0, Shapes(I))) nd.Nodes.Add("Data Source: " & shpLayers(SelectedLayer).CellValue(8, Shapes(I))) nd.Nodes.Add("Address: " & shpLayers(SelectedLayer).CellValue(10, Shapes(I))) Next I 'Draw a thick cyan circle around each selected point SelectBoxesLayer = AxMap1.NewDrawing(MapWinGIS.tkDrawReferenceList.dlSpatiallyReferencedList) For I = 0 To Shapes.GetUpperBound(0) Dim pt As MapWinGIS.Point pt = shpLayers(SelectedLayer).QuickPoint(Shapes(I), 0) AxMap1.DrawCircle(pt.x, pt.y, 11, Convert.ToUInt32(RGB(0, 200, 200)), False) AxMap1.DrawCircle(pt.x, pt.y, 12, Convert.ToUInt32(RGB(0, 200, 200)), False) AxMap1.DrawCircle(pt.x, pt.y, 13, Convert.ToUInt32(RGB(0, 200, 200)), False) Next I End Sub

Code Posted by Shade1974 on January 16, 2006