不用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;
        }
原文地址:https://www.cnblogs.com/gisoracle/p/1631839.html