ArcEngine遍历Map中的图层

/// <summary>
        /// 获得要素图层
        /// </summary>
        /// <param name="pMap"></param>
        /// <returns></returns>
        public static IFeatureLayer[] GetFeatureLayers(IMap pMap)
        {
            IFeatureLayer pFeatLayer;
            ICompositeLayer pCompLayer;
            List<IFeatureLayer> pList = new List<IFeatureLayer>();
            //遍历地图
            for (int i = 0; i < pMap.LayerCount; i++)
            {
                if (pMap.get_Layer(i) is IFeatureLayer)
                {
                    //获得图层要素
                    pFeatLayer = pMap.get_Layer(i) as IFeatureLayer;
                    pList.Add(pFeatLayer);
                }
                else if (pMap.get_Layer(i) is IGroupLayer)
                {
                    //遍历图层组
                    pCompLayer = pMap.get_Layer(i) as ICompositeLayer;
                    for (int j = 0; j < pCompLayer.Count; j++)
                    {
                        if (pCompLayer.get_Layer(j) is IFeatureLayer)
                        {
                            pFeatLayer = pCompLayer.get_Layer(j) as IFeatureLayer;
                            pList.Add(pFeatLayer);
                        }
                    }
                }
            } 
            return pList.ToArray();
        }

    原文作者:数据结构之图
    原文地址: https://blog.csdn.net/likekobe2012/article/details/44154469
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞