Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I need a bit of help with using the iBufferContruction interface, my overall goal is that the user clicks on the map, a graphic is created and then buffered,at multiple distances and then stored in a featureclass

So far, i can create a single buffer (i know if it created because the length that gets returned is correct), however when I store it in my FC the shape is empty.

Here's the code:

Private Sub Buffer_MouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)

'Get the location of the mouse and set it to the point
Set m_pPoint = m_pMxDoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y)

'new marker element on the map
Set m_pElement = New MarkerElement

'set the element property
m_pElement.Geometry = m_pPoint

Set m_pGraphics = m_pMap

m_pGraphics.AddElement m_pElement, 0 'Grpahic for the point click.

Set m_pAC = m_pMxDoc.ActiveView

'refresh the map
m_pAC.PartialRefresh esriViewGraphics, Nothing, Nothing
Dim pPoly As IPolygon4
Set pPoly = New Polygon

'Dim pPoly As IPolygonElement
'Set pPoly = New PolygonElement

Dim pBC As IBufferConstruction
Set pBC = New BufferConstruction

'Dim pBCProp As IBufferConstructionProperties
'Set pBCProp = pBC
'pBCProp.ExplodeBuffers = True

Set pPoly = pBC.Buffer(m_pElement.Geometry, 200)
Debug.Print pPoly.Length ' RETURNS 1256.63706143592

Dim pFeat As IFeature
Dim pfeatureCursor As IFeatureCursor
Dim pfeatureBuffer As IFeatureBuffer

Set pfeatureBuffer = m_pBufferFClass.CreateFeatureBuffer
Set pfeatureCursor = m_pBufferFClass.Insert(True)
Set pFeat = pfeatureBuffer

pfeatureCursor.InsertFeature pfeatureBuffer
Set pFeat.Shape = pPoly

m_pAC.PartialRefresh esriViewGeography, Nothing, Nothing

Where am I going wrong? Also has anyone got any code examples with creating multiple buffers at various distances?


1 Answer 1

Stupid mistake the line

Set pFeat.Shape = pPoly

should have been above

pfeatureCursor.InsertFeature pfeatureBuffer

This site is currently not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .