AnsweredAssumed Answered arcobjects draw a transparent polygon, then perform a spatial query

Question asked by littleleaf on Aug 7, 2014

Hi everybody,


Actually I am struggle this issue for quick a few days. What I want to develop is to draw a transparent polygon on the map, after that perform a spatial query (get polylines on a layer intersect the polygon drawn). I follow the examples from ESRI and several experts from internet, but still cannot make it work.


The first step, draw a transparent polygon on map, I followed the bellowing "Draw Polygon Snippet" from ESRI website, but the strange thing is the start point of the polygon always at the top of the map:


Public Sub DrawPolygon(ByVal activeView As ESRI.ArcGIS.Carto.IActiveView)


  If activeView Is Nothing Then


  End If


  Dim screenDisplay As ESRI.ArcGIS.Display.IScreenDisplay = activeView.ScreenDisplay


  ' Constant

  screenDisplay.StartDrawing(screenDisplay.hDC, CShort(ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache))

  Dim rgbColor As ESRI.ArcGIS.Display.IRgbColor = New ESRI.ArcGIS.Display.RgbColorClass

  rgbColor.Red = 255


  Dim color As ESRI.ArcGIS.Display.IColor = rgbColor ' Implicit Cast

  Dim simpleFillSymbol As ESRI.ArcGIS.Display.ISimpleFillSymbol = New ESRI.ArcGIS.Display.SimpleFillSymbolClass

  simpleFillSymbol.Color = color


  Dim symbol As ESRI.ArcGIS.Display.ISymbol = TryCast(simpleFillSymbol, ESRI.ArcGIS.Display.ISymbol) ' Dynamic Cast

  Dim rubberBand As ESRI.ArcGIS.Display.IRubberBand = New ESRI.ArcGIS.Display.RubberPolygonClass

  Dim geometry As ESRI.ArcGIS.Geometry.IGeometry = rubberBand.TrackNew(screenDisplay, symbol)





End Sub


And how to select all the features (in a polyline layer) intersect the polygon? All the steps will be perform after clicking a button.


Can anybody kindly give me advice? Thanks.