/// <summary>
/// 按照名字查询axMapControl中图层
/// </summary>
/// <param name="axMapCtl">axMapControl</param>
/// <param name="strLayerName">图层名</param>
/// <returns>ILayer</returns>
public ILayer findLayerByName(AxMapControl axMapCtl, string strLayerName)
{
//MessageBox.Show(axMapCtl.LayerCount.ToString());
ILayer pLayer = null;
ILayer pLtemp = null;
for (int i = 0; i < axMapCtl.LayerCount; i++)
{
pLtemp = axMapCtl.get_Layer(i);
if (pLtemp is IGroupLayer)//图层分组
{
ICompositeLayer pGL = pLtemp as ICompositeLayer;//查询含IGroupLayer的图层时,要用到ICompositeLayer 接口
for (int j = 0; j < pGL.Count; j++)
{
if (pGL.get_Layer(j).Name == strLayerName) ;
{
pLayer = pGL.get_Layer(j);
}
}
}
if (pLtemp.Name == strLayerName)
{
pLayer = pLtemp;
}
}
return pLayer;
/// 按照名字查询axMapControl中图层
/// </summary>
/// <param name="axMapCtl">axMapControl</param>
/// <param name="strLayerName">图层名</param>
/// <returns>ILayer</returns>
public ILayer findLayerByName(AxMapControl axMapCtl, string strLayerName)
{
//MessageBox.Show(axMapCtl.LayerCount.ToString());
ILayer pLayer = null;
ILayer pLtemp = null;
for (int i = 0; i < axMapCtl.LayerCount; i++)
{
pLtemp = axMapCtl.get_Layer(i);
if (pLtemp is IGroupLayer)//图层分组
{
ICompositeLayer pGL = pLtemp as ICompositeLayer;//查询含IGroupLayer的图层时,要用到ICompositeLayer 接口
for (int j = 0; j < pGL.Count; j++)
{
if (pGL.get_Layer(j).Name == strLayerName) ;
{
pLayer = pGL.get_Layer(j);
}
}
}
if (pLtemp.Name == strLayerName)
{
pLayer = pLtemp;
}
}
return pLayer;
}
int n = 0;
for (int m = 0; m < axPageCtlCommunity.ActiveView.FocusMap.LayerCount; m++)
{
if (axPageCtlCommunity.ActiveView.FocusMap.get_Layer(m).Name=="社区")
{
n = m;
}
}