/// <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();
}