添加公里网格(修改)

来源:互联网 发布:阿里云服务器网速很慢 编辑:程序博客网 时间:2024/04/28 20:39
 private void 添加公里网格ToolStripMenuItem_Click(object sender, EventArgs e)        {            IMap pMap;            IActiveView pPageActView = this.axPageLayoutControl1.PageLayout as IActiveView;            pMap = pPageActView.FocusMap;            IMapGrid pMapGrid;            IMeasuredGrid pMeaGrid = new MeasuredGridClass();            pMapGrid = pMeaGrid as IMapGrid;            pMeaGrid.FixedOrigin = true;            pMeaGrid.Units = pMap.MapUnits;            //间隔            pMeaGrid.XIntervalSize = 1000;            pMeaGrid.YIntervalSize = 1000;            //绘制范围  注意不要设为0,不然添加公里网之后会很卡            pMeaGrid.XOrigin = 40000000;            pMeaGrid.YOrigin = 40000000;            //属性            IProjectedGrid pProGird;            pProGird = pMeaGrid as IProjectedGrid;            pProGird.SpatialReference = pMap.SpatialReference;            pMapGrid.Name = "公里网";            //边框            ICalibratedMapGridBorder pGridBorder = new CalibratedMapGridBorderClass();            pGridBorder.BackgroundColor = GetColor(255, 255, 255);            pGridBorder.BorderWidth = 2;            pGridBorder.ForegroundColor = GetColor(0, 0, 0);            pGridBorder.Interval = 50;            pGridBorder.Alternating = true;            pMapGrid.Border = pGridBorder as IMapGridBorder;            //公里网字体            ICornerGridLabel pCornerLabel = new CornerGridLabelClass();            stdole.StdFont pFont = new stdole.StdFontClass();            pFont.Name = "Arial";            pFont.Size = 12;            pCornerLabel.set_CornerLabel(esriGridCornerEnum.esriGridCornerLowerLeft, true);            //公里网样式            IPrincipalDigitsGridLabel pPrincipalDiaitsLabel = pCornerLabel as IPrincipalDigitsGridLabel;            pPrincipalDiaitsLabel.PrincipalDigitCount = 2;            pPrincipalDiaitsLabel.BaseDigitCount = 5;            pPrincipalDiaitsLabel.UnitSuffix = "m.";            pPrincipalDiaitsLabel.EastingSuffix = "E";            pPrincipalDiaitsLabel.NorthingSuffix = "N";            //显示的Label样式             IGridLabel pLabel = pPrincipalDiaitsLabel as IGridLabel;            pLabel.Font = pFont as stdole.IFontDisp;            pLabel.Color = GetColor(0, 0, 0);            pLabel.LabelOffset = 2;            pMapGrid.LabelFormat = pLabel;            //图形容器            IGraphicsContainer pGraphicsContainer;            pGraphicsContainer = pPageActView as IGraphicsContainer;            IMapFrame pMapFrame;            pMapFrame = pGraphicsContainer.FindFrame(pMap) as IMapFrame;            //添加公里网            IMapGrids pMapGrids = pMapFrame as IMapGrids;            pMapGrids.AddMapGrid(pMapGrid);            //刷新            pPageActView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null);        }
最终的效果<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">图:<img src="http://img.blog.csdn.net/20140923170907984?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQveGlhb3l1YW5mZW5f/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" /></span>
0 0
原创粉丝点击