阅读:2755回复:5
IIdentifyDialog的用法
<P>我想实现查询功能,想用IIdentifyDialog的 AddLayerIdentifyPoint函数,可总是不行,应怎么用?大家能给个例子吗?</P>
<P> dlg.Map = activeView.FocusMap;<BR> dlg.AddLayerIdentifyPoint(activeView.FocusMap.ActiveGraphicsLayer,.X,Y));</P> <P>下面是我用IIdentify接口做的,但效果差远了</P> <P>private IHookHelper m_HookHelper = new HookHelperClass();<BR> private IIdentifyDialog dlg = new IdentifyDialogClass();<BR> IFeatureIdentifyObj featIdObj;<BR> IIdentifyObj idObj;<BR> IMap map;<BR> IIdentify identify;<BR> IPoint point;<BR> IArray idArray; </P> <P>public override void OnMouseDown(int Button, int Shift, int X, int Y)<BR> {<BR> base.OnMouseDown (Button, Shift, X, Y);<BR> <BR> //Get the active view<BR> IActiveView activeView = m_HookHelper.ActiveView;<BR> map = activeView.FocusMap;<BR> identify = map.get_Layer(0) as IIdentify;<BR> point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);<BR> idArray = identify.Identify(point);</P> <P> if (idArray != null)<BR> {<BR> featIdObj = idArray.get_Element(0) as IFeatureIdentifyObj;<BR> idObj = featIdObj as IIdentifyObj;<BR> idObj.Flash(activeView.ScreenDisplay);<BR> MessageBox.Show("Layer: " + idObj.Layer.Name + "\n" + "Feature: " + idObj.Name);<BR> }<BR> }</P> |
|
|
1楼#
发布于:2005-09-04 19:22
<P>要什么效果?</P>
<P>和空间查询的原理是一样的</P> |
|
|
2楼#
发布于:2005-09-05 00:15
<P>就是象ArcGIS中的那种效果,用IdentifyDialog显示所有属性,我那个方法只能显示部分属性</P>
<P>我不太会用IdentifyDialog,不知点图形的时候,怎么在IdentifyDialog中把相应的信息显示出来,我用AddLayerIdentifyPoint函数,但是没反应,不知问题出在哪儿?</P> <P>dlg.AddLayerIdentifyPoint(activeView.FocusMap.ActiveGraphicsLayer,X,Y));</P> |
|
|
3楼#
发布于:2007-06-18 15:28
我用了上面的代码为什么获取不到点、线要素呢?每次都是idArray = null,各位多执教啊!
|
|
4楼#
发布于:2007-06-18 16:49
<P>呵呵,回答得晚了点,下面的例子用了AddLayerIdentifyOID来添加</P>
<P>Dim pMap As IMap <BR>Dim pContentsView As IContentsView <BR>Dim pfeaturel As IFeatureLayer <BR>Dim pEnumLayer As IEnumLayer <BR>Dim pLayer As ILayer <BR>Dim pIdentifyDialog As IIdentifyDialog <BR>Dim pIdentifyDialogProps As IIdentifyDialogProps <BR><BR><BR>Set PMXDoc = m_pApp.Document <BR>Set pMap = PMXDoc.FocusMap <BR>Set PActiveView = PMXDoc.FocusMap <BR>'Create a new IdentifyDialog and associate it <BR>'with the focus map and the map's display <BR>Set pIdentifyDialog = New IdentifyDialog <BR>Set pIdentifyDialogProps = pIdentifyDialog 'QI <BR>Set pIdentifyDialog.Map = PMXDoc.FocusMap <BR>Set pIdentifyDialog.Display = PActiveView.ScreenDisplay <BR><BR>'Clear the dialog on each mouse click <BR>pIdentifyDialog.ClearLayers <BR><BR>'Clear all the selectable layers <BR>Set pEnumLayer = pMap.Layers <BR>Set pLayer = pEnumLayer.Next <BR>Do Until pLayer Is Nothing <BR>If TypeOf pLayer Is IFeatureLayer Then <BR>Set pfeaturel = pLayer <BR>Dim pfeatureselect As IFeatureSelection <BR>Set pfeatureselect = pfeaturel <BR>Dim pselected As ISelectionSet <BR>Set pselected = pfeatureselect.SelectionSet <BR>Dim pCuros As ICursor <BR>pselected.Search Nothing, True, pCuros <BR><BR>Dim pfeature As IFeature <BR>Set pfeature = pCuros.NextRow <BR>Do Until pfeature Is Nothing <BR>pIdentifyDialog.AddLayerIdentifyOID pLayer, pfeature.OID <BR><BR><BR>Set pfeature = pCuros.NextRow <BR>Loop <BR><BR>End If <BR>Set pLayer = pEnumLayer.Next <BR>Loop <BR>pIdentifyDialog.Show <BR><BR></P> |
|
|
5楼#
发布于:2007-06-23 19:45
总统总是热心的啊!!!
|
|
|