欢迎来到天天文库
浏览记录
ID:40556389
大小:36.26 KB
页数:8页
时间:2019-08-04
《identify工具》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、首先判断identify工具是否启动boolshowidentify=false;//全局变量,identify工具是否启动publicvoididentify_Click(objectsender,EventArgse){showidentify=true;}然后在axMapControl1.OnMouseDown中添加代码:axMapControl1.OnMouseDown+=(sender,e)=>{if(e.button==1&&showidentify){axMapControl1.MousePointer=esriControlsMousePointer.esri
2、PointerArrow;#regionIdentifyIFeatureLayerpFL;IFeatureSelectionpFeatureSelection;IEnvelopepEnv;IGeometrypGeometry;ISpatialFilterpSpatialFilter;ISelectionSetpSelectionSet;IEnumIDspEnumIDs;IFeaturepFeature;//用于查询的矩形(相当于点的缓冲区,这样比生成缓冲区节省资源),//envelope的大小根据实际情况设定,以方便使用为准pEnv=newEnvelopeClass();pE
3、nv.PutCoords(e.mapX-200,e.mapY-200,e.mapX+200,e.mapY+200);pGeometry=pEnvasIGeometry;pSpatialFilter=newSpatialFilterClass();pSpatialFilter.Geometry=pGeometry;pSpatialFilter.SpatialRel=esriSpatialRelEnum.esriSpatialRelIntersects;//运用singleton模式设计窗体,只允许存在一个ShowAttributeTable实例identifyfrmShowAt
4、tribute=identify.CreateForm();frmShowAttribute.Show();frmShowAttribute.AttributeTreeView.Nodes.Clear();//首先清除上次结果frmShowAttribute.AttributeTreeView.ShowLines=true;frmShowAttribute.AttributeTreeView.ShowPlusMinus=true;frmShowAttribute.pActiveView=this.axMapControl1.ActiveView;frmShowAttribut
5、e.pMap=axMapControl1.Map;frmShowAttribute.pSFilter=pSpatialFilter;TreeNoderootNode=newTreeNode();rootNode.Text="属性信息";//添加根节点“属性信息”frmShowAttribute.AttributeTreeView.Nodes.Add(rootNode);for(inti=0;i6、.Visible&&pFL.Selectable){pFeatureSelection=pFLasIFeatureSelection;//选择之前先清除,这是个好习惯(除非是用Add方式)pFeatureSelection.Clear();pFeatureSelection.SelectFeatures(pSpatialFilter,esriSelectionResultEnum.esriSelectionResultNew,true);pSelectionSet=pFeatureSelection.SelectionSet;axMapControl1.ActiveView.7、Refresh();//如果选择集内有Featureif(pSelectionSet.Count>0){//构建图层节点并添加到根节点TreeNodelayerNameNode=newTreeNode();layerNameNode.ForeColor=Color.Green;layerNameNode.Text=pFL.Name;rootNode.Nodes.Add(layerNameNode);pEnumIDs=pSelectionSet.IDs;longid=pEnumIDs.Next();whi
6、.Visible&&pFL.Selectable){pFeatureSelection=pFLasIFeatureSelection;//选择之前先清除,这是个好习惯(除非是用Add方式)pFeatureSelection.Clear();pFeatureSelection.SelectFeatures(pSpatialFilter,esriSelectionResultEnum.esriSelectionResultNew,true);pSelectionSet=pFeatureSelection.SelectionSet;axMapControl1.ActiveView.
7、Refresh();//如果选择集内有Featureif(pSelectionSet.Count>0){//构建图层节点并添加到根节点TreeNodelayerNameNode=newTreeNode();layerNameNode.ForeColor=Color.Green;layerNameNode.Text=pFL.Name;rootNode.Nodes.Add(layerNameNode);pEnumIDs=pSelectionSet.IDs;longid=pEnumIDs.Next();whi
此文档下载收益归作者所有