wavvylia
路人甲
路人甲
  • 注册日期2003-07-28
  • 发帖数384
  • QQ
  • 铜币555枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1814回复:3

看看我的查询代码,错在哪里?

楼主#
更多 发布于:2004-12-21 11:59
<P>这段代码是实现IDentify的,对面查询没有问题,可是无法查询线和点(无法捕捉到线或点)。觉得很是奇怪,请问,错在哪里。</P>
<P>‘***************************************代码************************************</P>
<P>Private Function QueryTopMost(ByVal X As Long, ByVal Y As Long) As Boolean</P>
<P>   Dim pMap As IMap
   Dim pIdentify As IIdentify
   Dim pPoint As IPoint
   Dim pIDArray As IArray
   Dim pActiveView As IActiveView
   Dim i As Integer
   Dim blnHasFlash As Boolean '是否闪烁过了
   Dim intLayer As Integer
   Set pActiveView = m_pMap
 
   For intLayer = 0 To m_pMap.LayerCount - 1</P>
<P>      If m_pMap.Layer(intLayer).Visible Then
        
         Set pIdentify = m_pMap.Layer(intLayer) 'm_pLayerTop
         Set pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y)
         Set pIDArray = pIdentify.Identify(pPoint)
    
         If Not pIDArray Is Nothing Then</P>
<P>            Set m_pLayerTop = m_pMap.Layer(intLayer)</P>
<P>            Call IdentifyFlash(pIDArray, pActiveView, blnHasFlash)
            QueryTopMost = True
            Exit Function
         Else</P>
<P>            QueryTopMost = False
         End If</P>
<P>      End If</P>
<P>   Next intLayer</P>
<P>End Function
’*********************************************************************</P>
<P>当程序运行到Set pIDArray = pIdentify.Identify(pPoint)时,pIDArray 为Nothing,不知道为啥没有值?那个兄弟给指点一下。
</P>
喜欢0 评分0
wavvylia
路人甲
路人甲
  • 注册日期2003-07-28
  • 发帖数384
  • QQ
  • 铜币555枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2004-12-21 17:33
<P>查到原因了,原来代码执行到Set pIDArray = pIdentify.Identify(pPoint)时,它需要一个容差值的,也就是说他要求要给定一个很小的区域而不是一个点,这样它才能捕捉到IFeature,所以pIDArray为空也就不奇怪了。呵呵,希望大家不要再走此弯路。
</P>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部