不用mapcontrol获得一个mxd的图层
//不用mapcontrol获得一个mxd的图层
private static int getLayercount(string mxdFileName)
{
IMapDocument pMapDocument = new MapDocumentClass();
pMapDocument.Open(mxdFileName, "");
INetworkDataset networkDataset = null;
int num = 0;
//iterate all the maps
for (int cMap = 0; cMap < pMapDocument.MapCount; cMap++)
{
for (int cLayer = 0; cLayer < pMapDocument.get_Map(cMap).LayerCount; cLayer++)
{
ILayer pLayer = pMapDocument.get_Map(cMap).get_Layer(cLayer);
MessageBox.Show(pLayer.Name);
num++;
}
}
return num;
}
private static int getLayercount(string mxdFileName)
{
IMapDocument pMapDocument = new MapDocumentClass();
pMapDocument.Open(mxdFileName, "");
INetworkDataset networkDataset = null;
int num = 0;
//iterate all the maps
for (int cMap = 0; cMap < pMapDocument.MapCount; cMap++)
{
for (int cLayer = 0; cLayer < pMapDocument.get_Map(cMap).LayerCount; cLayer++)
{
ILayer pLayer = pMapDocument.get_Map(cMap).get_Layer(cLayer);
MessageBox.Show(pLayer.Name);
num++;
}
}
return num;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步