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,繼續做事了,這時候很不淡定啊,班上的同學考研復習數學都搞完了,而我還沒開始。。。。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM