阅读:1814回复:3
看看我的查询代码,错在哪里?
<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> |
|
1楼#
发布于:2004-12-21 17:33
<P>查到原因了,原来代码执行到Set pIDArray = pIdentify.Identify(pPoint)时,它需要一个容差值的,也就是说他要求要给定一个很小的区域而不是一个点,这样它才能捕捉到IFeature,所以pIDArray为空也就不奇怪了。呵呵,希望大家不要再走此弯路。
</P> |
|