zoukankan      html  css  js  c++  java
  • ArcGIS Engine 9.2 + C# 2005 在pagelayout中添加经纬格网 函数

    直接调用就行,调用函数方法:

    CreateGraticuleMapGrid(AxpagelayputControl1.PageLayout);

    添加效果 是可以的,添加到自己的程序中需修改起始坐标、字体。颜色等设置。

    /// <summary>
            /// 为PageLayout对象添加经纬网格
            /// </summary>
            /// <param name="pPageLayout"></param>
            ///
            private void CreateGraticuleMapGrid(IPageLayout pPageLayout)
            {
                //获取MapFrame对象
                IActiveView pAcitiveView = pPageLayout as IActiveView;
                IMap pMap = pAcitiveView.FocusMap;
                IGraphicsContainer pGraphicsContainer = pAcitiveView as IGraphicsContainer;
                IMapFrame pMapFrame = pGraphicsContainer.FindFrame(pMap) as IMapFrame;

                IRgbColor rgbColor = new RgbColor();

                IMapGrids pMapGrids;
                IMapGrid pMapGrid;
             
                //Create the grid
                pMapGrid = new GraticuleClass();// (IGraticule)pServerContext.CreateObject("esriCarto.Graticule");
                pMapGrid.Name = "Map Grid";

                rgbColor.Red = 166;
                rgbColor.Green = 187;
                rgbColor.Blue = 208;
                IColor color = rgbColor as IColor;

                //Set the line symbol used to draw the grid
                ICartographicLineSymbol pLineSymbol;
                pLineSymbol = new CartographicLineSymbolClass();
                //pLineSymbol = (ICartographicLineSymbol)pServerContext.CreateObject("esriDisplay.CartographicLineSymbol");
                pLineSymbol.Cap = esriLineCapStyle.esriLCSButt;
                pLineSymbol.Width = 1;
                pLineSymbol.Color = color;

                pMapGrid.LineSymbol = pLineSymbol;
                pMapGrid.Border = null; // clear the default border;

                //Set the Tick Properties
                pMapGrid.TickLength = 15;
                pLineSymbol = new CartographicLineSymbolClass();
                //pLineSymbol = (ICartographicLineSymbol)pServerContext.CreateObject("esriDisplay.CartographicLineSymbol");
                pLineSymbol.Cap = esriLineCapStyle.esriLCSButt;
                pLineSymbol.Width = 1;
                pLineSymbol.Color = color;
                pMapGrid.TickLineSymbol = pLineSymbol;
                pMapGrid.TickMarkSymbol = null; //clear the default
                pMapGrid.LabelFormat.Font.Size = 20;
               
                //Set the Sub Tick Properties
                pMapGrid.SubTickCount = 5;
                pMapGrid.SubTickLength = 10;
                pLineSymbol = new CartographicLineSymbolClass();
                //pLineSymbol = (ICartographicLineSymbol)pServerContext.CreateObject("esriDisplay.CartographicLineSymbol");
                pLineSymbol.Cap = esriLineCapStyle.esriLCSButt;
                pLineSymbol.Width = 0.1;
                pLineSymbol.Color = color;
                pMapGrid.SubTickLineSymbol = pLineSymbol;

                //Marshal.ReleaseComObject(pLineSymbol);

                //Set the Grid labels properties
                IGridLabel pGridLabel;
                pGridLabel = pMapGrid.LabelFormat;
                pGridLabel.LabelOffset = 15;

                stdole.StdFont pFont = new stdole.StdFont();
                pFont.Name = "Arial";
                pFont.Size = 16;

                pMapGrid.LabelFormat.Font = pFont as stdole.IFontDisp;

                //Set the Tick, SubTick, Label Visibility along the 4 sides of the grid
                pMapGrid.SetTickVisibility(true, true, true, true);
                pMapGrid.SetSubTickVisibility(true, true, true, true);
                pMapGrid.SetLabelVisibility(true, true, true, true);

                //Make map grid visible, so it gets drawn when Active View is updated
                pMapGrid.Visible = true;

                //Set the IMeasuredGrid properties
                IMeasuredGrid pMeasuredGrid;
                pMeasuredGrid = pMapGrid as IMeasuredGrid;
                pMeasuredGrid.FixedOrigin = true;
                pMeasuredGrid.XIntervalSize = 0.5; //meridian interval
                pMeasuredGrid.XOrigin = 109; //shift grid 5
                pMeasuredGrid.YIntervalSize = 0.5; //parallel interval
                pMeasuredGrid.YOrigin = 40; //shift grid 5

                // add mapg grid to Layout and refresh
                pMapGrids = pMapFrame as IMapGrids;
                pMapGrids.AddMapGrid(pMapGrid);
            }

  • 相关阅读:
    高校教师职评
    高校教师曝职评内幕:混行政圈比科研圈更重要
    【50.88%】【Codeforces round 382B】Urbanization
    【64.22%】【codefoces round 382A】Ostap and Grasshopper
    【u253】售货厅
    【u250】manhattan
    【19.77%】【codeforces 570D】Tree Requests
    【t063】最聪明的机器人
    Java Web整合开发(38) -- Log4J
    公网 or 内网
  • 原文地址:https://www.cnblogs.com/yuxuetaoxp/p/1710026.html
Copyright © 2011-2022 走看看