gis_eternal
路人甲
路人甲
  • 注册日期2004-09-22
  • 发帖数105
  • QQ
  • 铜币407枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:2445回复:5

IIdentifyDialog的用法

楼主#
更多 发布于:2005-09-04 17:36
<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>
喜欢0 评分0
山高人为峰
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15946
  • QQ554730525
  • 铜币25338枚
  • 威望15363点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2005-09-04 19:22
<P>要什么效果?</P>
<P>和空间查询的原理是一样的</P>
举报 回复(0) 喜欢(0)     评分
gis_eternal
路人甲
路人甲
  • 注册日期2004-09-22
  • 发帖数105
  • QQ
  • 铜币407枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2005-09-05 00:15
<P>就是象ArcGIS中的那种效果,用IdentifyDialog显示所有属性,我那个方法只能显示部分属性</P>
<P>我不太会用IdentifyDialog,不知点图形的时候,怎么在IdentifyDialog中把相应的信息显示出来,我用AddLayerIdentifyPoint函数,但是没反应,不知问题出在哪儿?</P>
<P>dlg.AddLayerIdentifyPoint(activeView.FocusMap.ActiveGraphicsLayer,X,Y));</P>
山高人为峰
举报 回复(0) 喜欢(0)     评分
langyan8973
路人甲
路人甲
  • 注册日期2006-07-12
  • 发帖数90
  • QQ
  • 铜币456枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2007-06-18 15:28
我用了上面的代码为什么获取不到点、线要素呢?每次都是idArray = null,各位多执教啊!
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15946
  • QQ554730525
  • 铜币25338枚
  • 威望15363点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
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>
举报 回复(0) 喜欢(0)     评分
gzstyxb
路人甲
路人甲
  • 注册日期2004-09-22
  • 发帖数358
  • QQ
  • 铜币1045枚
  • 威望0点
  • 贡献值0点
  • 银元0个
5楼#
发布于:2007-06-23 19:45
总统总是热心的啊!!!
由爱故生忧, 由爱故生怖. 若离于爱者, 无忧亦无怖.
举报 回复(0) 喜欢(0)     评分
游客

返回顶部