FeatureIdentifyObject Example

该代码示例展示了如何使用 IIdentify 接口实现地图上的特征识别功能。通过鼠标的点击位置获取地图上的要素,并报告被选中要素的部分属性信息。
部署运行你感兴趣的模型镜像

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
 

您可能感兴趣的与本文相关的镜像

Qwen3-8B

Qwen3-8B

文本生成
Qwen3

Qwen3 是 Qwen 系列中的最新一代大型语言模型,提供了一整套密集型和专家混合(MoE)模型。基于广泛的训练,Qwen3 在推理、指令执行、代理能力和多语言支持方面取得了突破性进展

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值