ArcGIS Add-in开发(一)--获取选定要素的属性值

     刚刚接触AE开发,记录一下自己的学习心得!

     欢迎大家一起交流探讨!

     最近做大赛,突然想到可以让项目更加直观的操作,就在项目中加了幅底图(底图很简单)

     我想在arcmap中选中相应的要素后,在后台通过写代码的方式获取底图的属性表里面指定字段相应的值。

如图所示,我用arcmap工具栏上工具拉框选中我的目标要素(点220)

我想在后台获取他的属性表中“井号”字段的值

            IMxDocument mxDoc = null;
            ILayer layer = null;
            if (ArcMap.Application.Document as IMxDocument != null)
            {
                mxDoc = ArcMap.Application.Document as IMxDocument;
            }
            IMap map = mxDoc.FocusMap;

            layer = GetLayer(map, "Point");
            IFeatureLayer featureLayer = layer as IFeatureLayer;
            IFeatureSelection featureSelection = featureLayer as IFeatureSelection;
            long id = featureSelection.SelectionSet.IDs.Next(); 
            IFeatureClass featureClass = featureLayer.FeatureClass;

            IQueryFilter queryFilter = new QueryFilterClass();  
            queryFilter.WhereClause = "OBJECTID =" + id;   
            int fieldPosition = featureClass.FindField("井号");  
            IFeatureCursor featureCursor = featureClass.Search(queryFilter, true);
            IFeature feature = null;
            while ((feature = featureCursor.NextFeature()) != null)
            {
                Form1 frm = new Form1(feature.get_Value(fieldPosition).ToString());
                frm.Show();
            }

其实add-in开发跟普通AE开发没什么区别,只不过宿主是arcmap罢了,小弟刚刚接触AE,欢迎大家交流啊!

OK,继续做事了,这时候很不淡定啊,班上的同学考研复习数学都搞完了,而我还没开始。。。。

posted @ 2013-07-23 19:45  国产毛毛虫  阅读(5575)  评论(0编辑  收藏  举报