C#AE实现框选要素

该方法应该放在鼠标事件下,通过鼠标点击来执行此方法已达到点击后框选要素

IGeometry geometry = axMapControl1.TrackRectangle();
                    axMapControl1.Map.SelectByShape(geometry,null, false);
                    axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);


                    // 获取选择集  
                    ISelection pSelection = axMapControl1.Map.FeatureSelection;

                    // 打开属性标签  
                    IEnumFeatureSetup pEnumFeatureSetup = pSelection as IEnumFeatureSetup;
                    pEnumFeatureSetup.AllFields = true;
                    // 获取要素  
                    IEnumFeature pEnumFeature = pSelection as IEnumFeature;
                    IFeature pFeature = pEnumFeature.Next();
                    IFeatureLayer[] players = new IFeatureLayer[axMapControl1.LayerCount];
                    
                    FeatureLayer pFeatureLayer = new FeatureLayer();
                    IFeatureLayer player = pFeatureLayer as IFeatureLayer;
                    IFeatureSelection pFeatureSelection = pFeatureLayer as IFeatureSelection;
                    while (pFeature != null)
                    {
                        //pFeatureSelection.Add(pFeature);
                        pFeature = pEnumFeature.Next();
                    }

猜你喜欢

转载自blog.csdn.net/qq_38370387/article/details/89189224