1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > ArcEngine添加指北针 比例尺 图例(注意UID值)

ArcEngine添加指北针 比例尺 图例(注意UID值)

时间:2021-05-21 02:11:36

相关推荐

ArcEngine添加指北针 比例尺 图例(注意UID值)

指北针

C#代码publicvoidAddNorthArrow(IPageLayoutpageLayout) { IGraphicsContainercontainer=pageLayoutasIGraphicsContainer; IActiveViewactiveView=pageLayoutasIActiveView; //获得MapFrame IFrameElementframeElement=container.FindFrame(activeView.FocusMap); IMapFramemapFrame=frameElementasIMapFrame; //根据MapSurround的uid,创建相应的MapSurroundFrame和MapSurround UIDuid=newUIDClass(); uid.Value="esriCarto.MarkerNorthArrow"; IMapSurroundFramemapSurroundFrame=mapFrame.CreateSurroundFrame(uid,null); //设置MapSurroundFrame中指北针的点符号 IMapSurroundmapSurround=mapSurroundFrame.MapSurround; IMarkerNorthArrowmarkerNorthArrow=mapSurroundasIMarkerNorthArrow; IMarkerSymbolmarkerSymbol=markerNorthArrow.MarkerSymbol; markerSymbol.Size=18; markerNorthArrow.MarkerSymbol=markerSymbol; //QI,确定mapSurroundFrame的位置 IElementelement=mapSurroundFrameasIElement; IEnvelopeenvelope=newEnvelopeClass(); envelope.PutCoords(0.2,0.2,5,5); element.Geometry=envelope; //使用IGraphicsContainer接口添加显示 container.AddElement(element,0); activeView.Refresh(); }

比例尺

C#代码publicvoidAddScalebar(IPageLayoutpageLayout) { IGraphicsContainercontainer=pageLayoutasIGraphicsContainer; IActiveViewactiveView=pageLayoutasIActiveView; //获得MapFrame IFrameElementframeElement=container.FindFrame(activeView.FocusMap); IMapFramemapFrame=frameElementasIMapFrame; //根据MapSurround的uid,创建相应的MapSurroundFrame和MapSurround UIDuid=newUIDClass(); uid.Value="esriCarto.AlternatingScaleBar"; IMapSurroundFramemapSurroundFrame=mapFrame.CreateSurroundFrame(uid,null); //设置MapSurroundFrame中比例尺的样式 IMapSurroundmapSurround=mapSurroundFrame.MapSurround; IScaleBarmarkerScaleBar=((IScaleBar)mapSurround); markerScaleBar.LabelPosition=esriVertPosEnum.esriBelow; markerScaleBar.UseMapSettings(); //QI,确定mapSurroundFrame的位置 IElementelement=mapSurroundFrameasIElement; IEnvelopeenvelope=newEnvelopeClass(); envelope.PutCoords(0.2,0.2,1,2); element.Geometry=envelope; //使用IGraphicsContainer接口添加显示 container.AddElement(element,0); activeView.Refresh(); }

图例

C#代码privatevoidAddLegend(IPageLayoutpageLayout) { IActiveViewpActiveView=pageLayoutasIActiveView; IGraphicsContainercontainer=pageLayoutasIGraphicsContainer; //获得MapFrame IMapFramemapFrame=container.FindFrame(pActiveView.FocusMap)asIMapFrame; //根据MapSurround的uid,创建相应的MapSurroundFrame和MapSurround UIDuid=newUIDClass(); uid.Value="esriCarto.Legend"; IMapSurroundFramemapSurroundFrame=mapFrame.CreateSurroundFrame(uid,null); //设置图例的Title ILegend2legend=mapSurroundFrame.MapSurroundasILegend2; legend.Title="地图图例"; ILegendFormatformat=newLegendFormatClass(); ITextSymbolsymbol=newTextSymbolClass(); symbol.Size=4; format.TitleSymbol=symbol; legend.Format=format; //QI,确定mapSurroundFrame的位置 IElementelement=mapSurroundFrameasIElement; IEnvelopeenvelope=newEnvelopeClass(); envelope.PutCoords(2,2,8,8); element.Geometry=envelope; //使用IGraphicsContainer接口添加显示 container.AddElement(element,0); pActiveView.Refresh(); }

指北针

C#代码publicvoidAddNorthArrow(IPageLayoutpageLayout) { IGraphicsContainercontainer=pageLayoutasIGraphicsContainer; IActiveViewactiveView=pageLayoutasIActiveView; //获得MapFrame IFrameElementframeElement=container.FindFrame(activeView.FocusMap); IMapFramemapFrame=frameElementasIMapFrame; //根据MapSurround的uid,创建相应的MapSurroundFrame和MapSurround UIDuid=newUIDClass(); uid.Value="esriCarto.MarkerNorthArrow"; IMapSurroundFramemapSurroundFrame=mapFrame.CreateSurroundFrame(uid,null); //设置MapSurroundFrame中指北针的点符号 IMapSurroundmapSurround=mapSurroundFrame.MapSurround; IMarkerNorthArrowmarkerNorthArrow=mapSurroundasIMarkerNorthArrow; IMarkerSymbolmarkerSymbol=markerNorthArrow.MarkerSymbol; markerSymbol.Size=18; markerNorthArrow.MarkerSymbol=markerSymbol; //QI,确定mapSurroundFrame的位置 IElementelement=mapSurroundFrameasIElement; IEnvelopeenvelope=newEnvelopeClass(); envelope.PutCoords(0.2,0.2,5,5); element.Geometry=envelope; //使用IGraphicsContainer接口添加显示 container.AddElement(element,0); activeView.Refresh(); }

比例尺

C#代码publicvoidAddScalebar(IPageLayoutpageLayout) { IGraphicsContainercontainer=pageLayoutasIGraphicsContainer; IActiveViewactiveView=pageLayoutasIActiveView; //获得MapFrame IFrameElementframeElement=container.FindFrame(activeView.FocusMap); IMapFramemapFrame=frameElementasIMapFrame; //根据MapSurround的uid,创建相应的MapSurroundFrame和MapSurround UIDuid=newUIDClass(); uid.Value="esriCarto.AlternatingScaleBar"; IMapSurroundFramemapSurroundFrame=mapFrame.CreateSurroundFrame(uid,null); //设置MapSurroundFrame中比例尺的样式 IMapSurroundmapSurround=mapSurroundFrame.MapSurround; IScaleBarmarkerScaleBar=((IScaleBar)mapSurround); markerScaleBar.LabelPosition=esriVertPosEnum.esriBelow; markerScaleBar.UseMapSettings(); //QI,确定mapSurroundFrame的位置 IElementelement=mapSurroundFrameasIElement; IEnvelopeenvelope=newEnvelopeClass(); envelope.PutCoords(0.2,0.2,1,2); element.Geometry=envelope; //使用IGraphicsContainer接口添加显示 container.AddElement(element,0); activeView.Refresh(); }

图例

C#代码privatevoidAddLegend(IPageLayoutpageLayout) { IActiveViewpActiveView=pageLayoutasIActiveView; IGraphicsContainercontainer=pageLayoutasIGraphicsContainer; //获得MapFrame IMapFramemapFrame=container.FindFrame(pActiveView.FocusMap)asIMapFrame; //根据MapSurround的uid,创建相应的MapSurroundFrame和MapSurround UIDuid=newUIDClass(); uid.Value="esriCarto.Legend"; IMapSurroundFramemapSurroundFrame=mapFrame.CreateSurroundFrame(uid,null); //设置图例的Title ILegend2legend=mapSurroundFrame.MapSurroundasILegend2; legend.Title="地图图例"; ILegendFormatformat=newLegendFormatClass(); ITextSymbolsymbol=newTextSymbolClass(); symbol.Size=4; format.TitleSymbol=symbol; legend.Format=format; //QI,确定mapSurroundFrame的位置 IElementelement=mapSurroundFrameasIElement; IEnvelopeenvelope=newEnvelopeClass(); envelope.PutCoords(2,2,8,8); element.Geometry=envelope; //使用IGraphicsContainer接口添加显示 container.AddElement(element,0); pActiveView.Refresh(); }

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。