您的位置:首页 > 其它

[ArcEngine地图制图系列]—添加比例尺

2015-05-11 11:18 946 查看
      private void AddScaleBar(IActiveView pActiveView, IEnvelope pEnv)

        {

            try

            {

                IGraphicsContainer pGraphicsContainer = pActiveView.GraphicsContainer;

                IMapFrame pMapFrame = pGraphicsContainer.FindFrame(pActiveView.FocusMap) as IMapFrame;

                IMapSurroundFrame pMapSurroundFrame = new MapSurroundFrameClass();

                pMapSurroundFrame.MapFrame = pMapFrame;

                IScaleBar pScaleBar = SymbolUtilty.GetItemFromServerStyle("Scale Bars", "Alternating Scale Bar 1").Item as IScaleBar;

                //此处修改比例尺属性

                pScaleBar.Units = esriUnits.esriMeters;

                pScaleBar.UnitLabel = "米";

                pScaleBar.Divisions = (short)3;

                pScaleBar.Subdivisions = 1;

                //IStyleGalleryItem pStyleGalleryItem = SymbolUtilty.GetItemFromServerStyle("Scale Bars", "Alternating Scale Bar 1");

                pMapSurroundFrame.MapSurround = (IMapSurround)pScaleBar;

                IElement pElement = axPageControl.FindElementByName("ScaleBar");

                if (pElement != null)

                {

                    pGraphicsContainer.DeleteElement(pElement);  //删除已经存在的比例尺

                }

                IElementProperties pElePro = null;

                pElement = (IElement)pMapSurroundFrame;

                pElement.Geometry = (IGeometry)pEnv;

                pElePro = pElement as IElementProperties;

                pElePro.Name = "ScaleBar";

                pGraphicsContainer.AddElement(pElement, 0);

                pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

            }

            catch (Exception e)

            {

                MessageBox.Show(e.ToString());

            }

        }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  IScaleBar ArcGISEngine