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
FeatureIdentifyObject Example
最新推荐文章于 2021-08-26 14:36:25 发布
该代码示例展示了如何使用 IIdentify 接口实现地图上的特征识别功能。通过鼠标的点击位置获取地图上的要素,并报告被选中要素的部分属性信息。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
Qwen3-8B
文本生成
Qwen3
Qwen3 是 Qwen 系列中的最新一代大型语言模型,提供了一整套密集型和专家混合(MoE)模型。基于广泛的训练,Qwen3 在推理、指令执行、代理能力和多语言支持方面取得了突破性进展
689

被折叠的 条评论
为什么被折叠?



