FeatureIdentifyObject Example

The following UIToolControl code uses the IIdentify::Identify method to get the FeatureIdentifyObject objects at the mouse-click location. Then, using the IIdentifyObj interface, some of the properties of the feature first identified are reported.

Private Sub UIToolControl1_MouseDown(ByVal button As Long, _
              ByVal shift As Long, ByVal x As Long, ByVal y As Long)
  Dim pMxApp As IMxApplication
  Dim pDoc As IMxDocument
  Dim pMap As IMap
  Dim pIdentify As IIdentify
  Dim pIDArray As IArray
  Dim pFeatIdObj As IFeatureIdentifyObj
  Dim pIdObj As IIdentifyObj
  Dim tol As Long
  Dim pEnv As IEnvelope
  Dim r As tagRECT
  
  Set pMxApp = Application
  Set pDoc = Application.Document
  Set pMap = pDoc.FocusMap
  Set pIdentify = pMap.Layer(0)
  tol = pDoc.SearchTolerancePixels
  
  'consruct a small rectangle out of the x,y coord and the document's pixel tolerance
  r.Left = x - tol 'upper left x, top left is 0,0
  r.Top = y - tol 'upper left y, top left is 0,0
  r.Right = x + tol 'lower right x, top left is 0,0
  r.bottom = y + tol 'lower right y, top left is 0,0
  
  'Tranform the device rectange into a geographic rectangle via the display transformation
  Set pEnv = New Envelope
  pMxApp.Display.DisplayTransformation.TransformRect pEnv, r, esriTransformPosition + esriTransformToMap
  
  'setup the spatial reference on the newly hydrated envelope
  Set pEnv.SpatialReference = pMap.SpatialReference
  
  'identify with the envelope
  Set pIDArray = pIdentify.Identify(pEnv)
  
  'Get the FeatureIdentifyObject
  If Not pIDArray Is Nothing Then
    Set pFeatIdObj = pIDArray.Element(0)
    Set pIdObj = pFeatIdObj
    pIdObj.Flash pMxApp.Display
    'Report info from FeatureIdentifyObject
    MsgBox "Layer: " & pIdObj.Layer.Name & vbNewLine & "Feature: " & pIdObj.Name
  Else
    MsgBox "No feature identified."
  End If
End Sub
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值