duckweeds 原文利用IIdentify接口实现点选和矩形选择要素
Identify接口定义了获得要素图层单个要素的属性的捷径方法。它有一个Identify方法,返回一个IArray数组对象。
将下列代码放入MouseDown事件中,可以实现点选或者矩形选择要素。
IMap pMap; IPoint pPoint; pMap = axMapControl1.Map; pPoint = axMapControl1.ToMapPoint(e.x, e.y); IIdentify pIdentify; pIdentify = (IIdentify)pMap.get_Layer(0); IArray pIDArray; IFeatureIdentifyObj pFeatIdObj; IIdentifyObj pIdObj; //点选 IEnvelope pEnv=new EnvelopeClass(); pEnv =axMapControl1.ActiveView.Extent; pEnv.Height= 100; pEnv.Width = 100; pEnv.CenterAt(pPoint); pIDArray = pIdentify.Identify(pEnv); //矩形选择 //IEnvelope testIRectangleElement; //testIRectangleElement = axMapControl1.TrackRectangle(); //pIDArray = pIdentify.Identify(testIRectangleElement); //i = pIDArray.Count; if (pIDArray != null) { for (int i = 0; i <= pIDArray.Count; i++) { pFeatIdObj = (IFeatureIdentifyObj)pIDArray.get_Element(i); pIdObj = (IIdentifyObj)pFeatIdObj; pIdObj.Flash(axMapControl1.ActiveView.ScreenDisplay); //消息显示查询目标的信息 MessageBox.Show("Layer:" + pIdObj.Layer.Name + "Feature:" + pIdObj.Name); } } else { MessageBox.Show("No feature identified."); } }
此外,有关使用Identify,实现点击查询并闪烁显示,并把查询要素的信息通过DataGridView显示出来。可参考本博文文章AE中Identify查询工具的实现。
没有整理与归纳的知识,一文不值!高度概括与梳理的知识,才是自己真正的知识与技能。 永远不要让自己的自由、好奇、充满创造力的想法被现实的框架所束缚,让创造力自由成长吧! 多花时间,关心他(她)人,正如别人所关心你的。理想的腾飞与实现,没有别人的支持与帮助,是万万不能的。
本文转自wenglabs博客园博客,原文链接:http://www.cnblogs.com/arxive/p/6113655.html
,如需转载请自行联系原作者