地图框选得到要素属性值

自己添加响应函数即可,以下为响应函数中的代码:

IMap pMap = pMapControl.Map;
            ISelectionEnvironment pSelEnvi = new SelectionEnvironmentClass();
            IEnvelope pEnv = new EnvelopeClass();
            pEnv = pMapControl.TrackRectangle();
            pMap.SelectByShape(pEnv, pSelEnvi, false);
            IFeatureSelection pFeatureSelection;
            IFeatureLayer pFeatureLayer;
            IFeature pFeature;
            pFeatureLayer = pMapControl.get_Layer(0) as FeatureLayer;
            pFeatureSelection = pFeatureLayer as IFeatureSelection;
            ISelectionSet pSelectionSet;
            pSelectionSet = pFeatureSelection.SelectionSet;
           // MessageBox.Show(pSelectionSet.Count.ToString());
            IEnumIDs pEnumIDs;
            IEnvelope pEnv2 = new EnvelopeClass();
            pEnumIDs = pSelectionSet.IDs;
            long id = pEnumIDs.Next();
            while (id != -1)
            {
                pFeature=pFeatureLayer.FeatureClass.GetFeature((int)id);
                pMapControl.FlashShape(pFeature.Shape, 3, 300, null); //闪烁要素
                pEnv2.Union(pFeature.Extent);
                //MessageBox.Show(pFeature.get_Value(4).ToString()); //得到要素属性值
                id = pEnumIDs.Next();
            }
            pMapControl.Extent = pEnv2;
            pMapControl.ActiveView.Refresh();

posted @ 2008-11-09 15:23  周文  阅读(471)  评论(0编辑  收藏  举报