資源描述:
《identify工具》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
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;//用于查詢的矩形(相當(dāng)于點的緩沖區(qū),這樣比生成緩沖區(qū)節(jié)省資源),//envelope的大小根據(jù)實際情況設(shè)定,以方便使用為準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模式設(shè)計窗體,只允許存在一個ShowAttributeTable實例identifyfrmShowAt
4、tribute=identify.CreateForm();frmShowAttribute.Show();frmShowAttribute.AttributeTreeView.Nodes.Clear();//首先清除上次結(jié)果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="屬性信息";//添加根節(jié)點“屬性信息”frmShowAttribute.AttributeTreeView.Nodes.Add(rootNode);for(inti=0;i6、.Visible&&pFL.Selectable){pFeatureSelection=pFLasIFeatureSelection;//選擇之前先清除,這是個好習(xí)慣(除非是用Add方式)pFeatureSelection.Clear();pFeatureSelection.SelectFeatures(pSpatialFilter,esriSelectionResultEnum.esriSelectionResultNew,true);pSelectionSet=pFeatureSelection.SelectionSet;axMapControl1.ActiveView.
7、Refresh();//如果選擇集內(nèi)有Featureif(pSelectionSet.Count>0){//構(gòu)建圖層節(jié)點并添加到根節(jié)點TreeNodelayerNameNode=newTreeNode();layerNameNode.ForeColor=Color.Green;layerNameNode.Text=pFL.Name;rootNode.Nodes.Add(layerNameNode);pEnumIDs=pSelectionSet.IDs;longid=pEnumIDs.Next();whi