基于AO/AE获取要素信息

基于AO/AE获取要素信息

1、基于AE获取要素简单信息

 Private Sub AxMapControl1_OnMouseDown(ByVal sender As Object, ByVal e As ESRI.ArcGIS.MapControl.IMapControlEvents2_OnMouseDownEvent) Handles AxMapControl1.OnMouseDown

 Me.AxMapControl1.MousePointer = ESRI.ArcGIS.SystemUI.esriControlsMousePointer.esriPointerIdentify

Dim pMap As IMap
            Dim i As Integer
            Dim groupLayer As IGroupLayer
            groupLayer = New GroupLayer
            For i = 0 To Me.AxMapControl1.Map.LayerCount - 1
                groupLayer.Add(Me.AxMapControl1.Map.Layer(i))
            Next
            Dim pPoint As IPoint
            pMap = Me.AxMapControl1.Map
            pPoint = Me.AxMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y)

            Dim pIdentify As IIdentify

            Dim pIDArray As IArray
            Dim pFeatIdObj As IFeatureIdentifyObj
            Dim pIdObj As IIdentifyObj
            pIdentify = groupLayer

            Dim pEnv As IEnvelope
            pEnv = New Envelope
            pEnv = Me.AxMapControl1.ActiveView.Extent
            pEnv.Height = 100
            pEnv.Width = 100
            pEnv.CenterAt(pPoint)

            pIDArray = pIdentify.Identify(pEnv)

            If Not pIDArray Is Nothing Then
                pFeatIdObj = pIDArray.Element(0)
                pIdObj = pFeatIdObj
                pIdObj.Flash(Me.AxMapControl1.ActiveView.ScreenDisplay)
                '消息显示查询目标的信息
                MsgBox("Layer:" & pIdObj.Layer.Name & vbNewLine & "Feature:" & pIdObj.Name)
            Else
                MsgBox("No feature identified.")
            End If
                       Me.AxMapControl1.MousePointer = ESRI.ArcGIS.SystemUI.esriControlsMousePointer.esriPointerDefault

End Sub

2、基于AO获取要素详细信息

Private Sub AxMapControl1_OnMouseDown(ByVal sender As Object, ByVal e As ESRI.ArcGIS.MapControl.IMapControlEvents2_OnMouseDownEvent) Handles AxMapControl1.OnMouseDown

 Me.AxMapControl1.MousePointer = ESRI.ArcGIS.SystemUI.esriControlsMousePointer.esriPointerIdentify

 Dim pActiveView As IActiveView
            pActiveView = Me.AxMapControl1.ActiveView
            Dim pIdentifyDialog As IIdentifyDialog
            Dim pIdentifyDialogProps As IIdentifyDialogProps
            Dim pEnumLayer As IEnumLayer
            Dim pLayer As ILayer


            pIdentifyDialog = New IdentifyDialog
            pIdentifyDialogProps = pIdentifyDialog 'QI
            pIdentifyDialog.Map = Me.AxMapControl1.Map
            pIdentifyDialog.Display = pActiveView.ScreenDisplay


            '//Clear the dialog on each mouse click
            pIdentifyDialog.ClearLayers()

            '//Perform an identify on all of the layers the dialog
            '//says are searchable
            pEnumLayer = pIdentifyDialogProps.Layers
            pEnumLayer.Reset()
            pLayer = pEnumLayer.Next
            Do While Not pLayer Is Nothing
                pIdentifyDialog.AddLayerIdentifyPoint(pLayer, e.x, e.y)
                pLayer = pEnumLayer.Next
            Loop
            pIdentifyDialog.Show()

                       Me.AxMapControl1.MousePointer = ESRI.ArcGIS.SystemUI.esriControlsMousePointer.esriPointerDefault

End Sub

 



GIS云中飞鹏 2007-05-22 15:29 发表评论   

你可能感兴趣的:(object,Integer,dialog,each,layer)