出图时加上指北针的代码

protected virtual void PutNorthArrow()
        {//地图指北针 目前没有处理   2007-10-22 by xxd
            double xMin,xMax,yMin,yMax;
            IEnvelope aFrameExtent=(this.MapFrame as IElement).Geometry .Envelope ;
            xMin = aFrameExtent.XMax-0.1-2;//指北针的宽度为2,高度为3,位置距离地图最上角0.1 0.1
            xMax = aFrameExtent.XMax-0.1;
            yMin = aFrameExtent.YMax-0.1-3;
            yMax = aFrameExtent.YMax-0.1;
            IEnvelope pEnv =new EnvelopeClass();
            pEnv.PutCoords( xMin,yMin,xMax,yMax);
            UID pID = new  UIDClass();
            pID.Value = "esriCarto.MarkerNorthArrow";
            IMapSurround pMapSurround  = this.CreateSurround(pID,pEnv,"North Arrow",this.MapFrame,this.PageLayout.PageLayout);
            IMarkerNorthArrow pMarkerNorthArrow = pMapSurround as IMarkerNorthArrow; //QI 
            ICharacterMarkerSymbol pCharacterMarkerSymbol = pMarkerNorthArrow.MarkerSymbol as ICharacterMarkerSymbol; //clones the symbol 
            pCharacterMarkerSymbol.CharacterIndex = 167 ;//change the symbol 
            pCharacterMarkerSymbol.Color = GeoUtilities.CreateColor (0,0,0);
            pCharacterMarkerSymbol.Angle = 0;
            pCharacterMarkerSymbol.Size = 100;
            pMarkerNorthArrow.MarkerSymbol = pCharacterMarkerSymbol;//'set it back  
            
//            pEnv.PutCoords(1, 1, 3.4, 2.4);
//            pID.Value = "esriCarto.Legend";//增加legend
//            pMapSurround = CreateSurround(pID, pEnv, "Legend", this.MapFrame,this.PageLayout.PageLayout); //Refresh the graphics 
           
        }
        public IMapSurround CreateSurround(UID pID, IEnvelope pEnv,string strName,IMapFrame pMapFrame,IPageLayout pPageLayout)
        {
            IGraphicsContainer pGraphicsContainer = pPageLayout as IGraphicsContainer;
            IActiveView pActiveView = pPageLayout as IActiveView;
            IMapSurroundFrame  pMapSurroundFrame = pMapFrame.CreateSurroundFrame(pID, null) ;//MapSurroundFrames are related to MapFrames MapFrames hold Maps
            pMapSurroundFrame.MapSurround.Name = this.ElementNamePrefix+strName; //Set the geometry of the MapSurroundFrame to give it a location 
            //Activate it and add it to the PageLayout's graphics container
            IElement pElement = pMapSurroundFrame as IElement;  //MapSurrounds are held in a MapSurroundFram
            pElement.Geometry = pEnv;
            pElement.Activate(pActiveView.ScreenDisplay); //'Allow the legend frame size to be altered after the legend has been  'added to the GraphicsContainer 
            ITrackCancel PTrack = new CancelTrackerClass();
            pElement.Draw(pActiveView.ScreenDisplay, PTrack );
            pGraphicsContainer.AddElement(pElement, 0 );
            //Re-apply the change to the Legend MapSurroundFrame Geometry 
            //pElement.Geometry = pEnv ;
            return pMapSurroundFrame.MapSurround;
        }
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值