指北针
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(); }