设置图层符号风格为用已有mxd里的同名图层风格

 1 //要加载的IFeatureClass
 2 IFeatureClass pFeatClass = dataset as IFeatureClass;
 3 //新建要加载到mxd文档中的图层
 4 IFeatureLayer pFeatLayer = new FeatureLayerClass();
 5 //设置新加图层的要素类
 6 pFeatLayer.FeatureClass = pFeatClass;
 7 //设置新家图层的名称
 8 pFeatLayer.Name = pFeatClass.AliasName;
 9 //GetRenderLayer函数实现从已配置好符号风格的mxd文档中的同名图层
10 IGeoFeatureLayer pGeoLayer = GetRenderLayer(pFeatClass.AliasName) as IGeoFeatureLayer;
11 //定义新加载图层为IGeoFeatureLayer类
12 IGeoFeatureLayer pNewGeolayer = pFeatLayer as IGeoFeatureLayer;
13 //为新加载图层设置符号风格
14 pNewGeolayer.Renderer = pGeoLayer.Renderer;

此功能适用于固定显示风格的成图加载等。

posted @ 2013-08-28 14:20  寻梦放歌  阅读(246)  评论(0编辑  收藏  举报