zoukankan      html  css  js  c++  java
  • Delphi ArcEngine 创建比例尺

     Delphi ArcEngine 创建比例尺,https://www.cnblogs.com/chinacodegear/archive/2009/03/19/1416410.html
    
    //本函数 是在 PageControl上拉选一个区域内 创建一个比例尺,比例尺的样式,我自己定义一个 枚举类型 如下
    
    type  
       ScaleType = (stAlternating, stDoubleAlternating, stHollow, stScaleLine, stSingleDivision, stSetpped);
    
    function InsertScaler(aePageLayoutControl: TPageLayoutControl; stType: ScaleType; sTitle: string): Boolean;
    var
       pPageLayout: IPageLayout;
       pScaleBar: IScaleBar;
       pMapFrame: IMapFrame;
       pMapSurroundFrame: IMapSurroundFrame;
       pMapSurround: IMapSurround;
       pElement : IElement;
       pElementPro: IElementProperties;
    
       pUID     : UID;
       pGraphicsContainer: IGraphicsContainer;
       pActiveMap: IActiveView;
       pMap     : IMap;
       pEnvelope: IEnvelope;
    
    begin
       //产生一个 UID 对象,使用它产生不同的 MapSurround 对象
       pUID := CoUID.Create as UID;
       pUID.Value := 'esriCarto.scalebar';
    
       pPageLayout := aePageLayoutControl.PageLayout;
    
       pActiveMap := pPageLayout as IActiveView;
    
     
       aePageLayoutControl.TrackCancel.Reset;
       pEnvelope := aePageLayoutControl.TrackRectangle;
    
       if (pEnvelope.IsEmpty) or (pActiveMap = nil) then
          Exit(False);
    
       pGraphicsContainer := pPageLayout as IGraphicsContainer;
       pActiveMap := pGraphicsContainer as IActiveView;
       pMap := pActiveMap.FocusMap;
    
       //获得与地图相关的 mapFrame
       pMapFrame := pGraphicsContainer.FindFrame(pMap) as IMapFrame;
    
       //产生MapSurroundFrame
       pMapSurroundFrame := pMapFrame.CreateSurroundFrame(pUID, nil);
    
       case stType of //比例尺样式选择
          stAlternating: pScaleBar := CoAlternatingScaleBar.Create as IScaleBar;
          stDoubleAlternating: pScaleBar := CoDoubleAlternatingScaleBar.Create as IScaleBar;
          stHollow: pScaleBar := CoHollowScaleBar.Create as IScaleBar;
          stScaleLine: pScaleBar := CoScaleLine.Create as IScaleBar;
          stSingleDivision: pScaleBar := CoSingleDivisionScaleBar.Create as IScaleBar;
          stSetpped: pScaleBar := CoSteppedScaleLine.Create as IScaleBar;
       end;
       //设置比例尺的属性
       pScaleBar.Division := 3;
       pScaleBar.Divisions := 3;
       pScaleBar.LabelGap := 4;
       pScaleBar.LabelPosition := esriAbove;//比例尺标签的 位置
       pScaleBar.Map := pMap;
       pScaleBar.Name := sTitle;
       pScaleBar.Subdivisions := 2;
    
       pScaleBar.Units := esriKilometers;
       pScaleBar.UnitLabelPosition := esriScaleBarAfterLabels;
       pScaleBar.UnitLabelGap := 4;
       pScaleBar.UnitLabel := '千米';
    
       pMapSurround := pScaleBar as IMapSurround;
       pMapSurroundFrame.MapSurround := pMapSurround;
       pElementPro := pMapSurroundFrame as IElementProperties;
       pElementPro.Name := '我的比例尺';
    
       //将mapsurroundframe添加到控件
       if not pEnvelope.IsEmpty then
       begin
          aePageLayoutControl.AddElement(pMapSurroundFrame as IElement, pEnvelope, EmptyParam, EmptyParam, 0);
          pActiveMap.PartialRefresh(esriViewGraphics, nil, nil);
          Result := True;
       end
       else
       begin     
          Result := False;
       end;
    
    end; 
  • 相关阅读:
    java不定参数列表---乔老师没讲,但是传智有讲
    java数据库连接模板代码通用收集
    java数据库连接模板代码通用收集
    BZOJ2060: [Usaco2010 Nov]Visiting Cows 拜访奶牛
    BZOJ1598: [Usaco2008 Mar]牛跑步
    BZOJ1710: [Usaco2007 Open]Cheappal 廉价回文
    manacher模板
    BZOJ1584: [Usaco2009 Mar]Cleaning Up 打扫卫生
    BZOJ1753: [Usaco2005 qua]Who's in the Middle
    BZOJ1828: [Usaco2010 Mar]balloc 农场分配
  • 原文地址:https://www.cnblogs.com/gisoracle/p/15643267.html
Copyright © 2011-2022 走看看