arcgis engine - 添加图例,指北针.
2015-01-19 14:11
369 查看
esri帮助提供了使用比例尺的方法: Working with map surrounds
主要代码为:
在实现地图同步后,分别获得IMap和IPageLayout对象,并调用之即可,如
esri也提供使用指北针的方法,主要方法为:
ref: http://blog.csdn.net/freeWayWalker/article/details/25633859
esri: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//00490000004w000000
主要代码为:
public void AddMapSurround(IPageLayout pageLayout, IActiveView activeView) { IMap map = activeView.FocusMap; IGraphicsContainer graphicsContainer = pageLayout as IGraphicsContainer; IFrameElement frameElement = graphicsContainer.FindFrame(map); IMapFrame mapFrame = (IMapFrame)frameElement; IMapSurroundFrame mapSurroundFrame = new MapSurroundFrameClass(); UID elementUID = new UIDClass(); //The value determines the type of MapSurroundFrame being added. elementUID.Value = "esriCarto.Legend"; //The CreateSurroundFrame method takes the UID of the element and an optional style. mapSurroundFrame = mapFrame.CreateSurroundFrame(elementUID, null); mapSurroundFrame.MapSurround.Name = "Legend"; //Cast the MapSurroundFrame as an element so it can be inserted into the page layout. IElement doc_Element = mapSurroundFrame as IElement; IElement mainMap_Element = mapFrame as IElement; IGeometry geometry = mainMap_Element.Geometry; IEnvelope mainMap_Envelope = geometry.Envelope; IEnvelope envelope = new EnvelopeClass(); double xMin = mainMap_Envelope.XMax + 1.5; double yMin = mainMap_Envelope.YMin + 1.5; double xMax = mainMap_Envelope.XMax - 1.5; double yMax = mainMap_Envelope.YMax - 1.5; envelope.PutCoords(xMin, yMin, xMax, yMax); doc_Element.Geometry = envelope as IGeometry; doc_Element.Activate(activeView.ScreenDisplay); graphicsContainer.AddElement(doc_Element, 0); activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
在实现地图同步后,分别获得IMap和IPageLayout对象,并调用之即可,如
//mapDoc.get_Map(0) IMap map; //map = map_Big.ActiveView as IMap; IPageLayout pageLayout = pageLayoutCtrl.ActiveView as IPageLayout; AddMapSurround(pageLayout, map_Big.ActiveView);
esri也提供使用指北针的方法,主要方法为:
public void AddNorthArrow(ESRI.ArcGIS.Carto.IPageLayout pageLayout, ESRI.ArcGIS.Carto.IMap map) { if(pageLayout == null || map == null) { return; } ESRI.ArcGIS.Geometry.IEnvelope envelope = new ESRI.ArcGIS.Geometry.EnvelopeClass(); envelope.PutCoords(0.2, 0.2, 5, 5); // Specify the location and size of the north arrow ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass(); uid.Value = "esriCarto.MarkerNorthArrow"; // Create a Surround. Set the geometry of the MapSurroundFrame to give it a location // Activate it and add it to the PageLayout's graphics container ESRI.ArcGIS.Carto.IGraphicsContainer graphicsContainer = pageLayout as ESRI.ArcGIS.Carto.IGraphicsContainer; // Dynamic Cast ESRI.ArcGIS.Carto.IActiveView activeView = pageLayout as ESRI.ArcGIS.Carto.IActiveView; // Dynamic Cast ESRI.ArcGIS.Carto.IFrameElement frameElement = graphicsContainer.FindFrame(map); ESRI.ArcGIS.Carto.IMapFrame mapFrame = frameElement as ESRI.ArcGIS.Carto.IMapFrame; // Dynamic Cast ESRI.ArcGIS.Carto.IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uid as ESRI.ArcGIS.esriSystem.UID, null); // Dynamic Cast ESRI.ArcGIS.Carto.IElement element = mapSurroundFrame as ESRI.ArcGIS.Carto.IElement; // Dynamic Cast element.Geometry = envelope; element.Activate(activeView.ScreenDisplay); graphicsContainer.AddElement(element, 0); ESRI.ArcGIS.Carto.IMapSurround mapSurround = mapSurroundFrame.MapSurround; // Change out the default north arrow ESRI.ArcGIS.Carto.IMarkerNorthArrow markerNorthArrow = mapSurround as ESRI.ArcGIS.Carto.IMarkerNorthArrow; // Dynamic Cast ESRI.ArcGIS.Display.IMarkerSymbol markerSymbol = markerNorthArrow.MarkerSymbol; ESRI.ArcGIS.Display.ICharacterMarkerSymbol characterMarkerSymbol = markerSymbol as ESRI.ArcGIS.Display.ICharacterMarkerSymbol; // Dynamic Cast characterMarkerSymbol.CharacterIndex = 200; // change the symbol for the North Arrow markerNorthArrow.MarkerSymbol = characterMarkerSymbol; }
ref: http://blog.csdn.net/freeWayWalker/article/details/25633859
esri: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//00490000004w000000
相关文章推荐
- ArcGIS Engine自定义工具类,实现添加图名,比例尺,指北针
- [AE] 地图整饰-添加地图框架元素(指北针、比例尺、图例、标题)
- 实现在PageLayout控件中添加了图例、指北针或比例
- ArcEngine添加指北针、比例尺、图例(注意UID值)
- AO+Java实现比例尺、指北针、图名、图例的添加(ArcGIS Add-in for Java)
- 添加图例和注解
- ArcGIS Engine 添加SDE数据库
- arcgis engine中添加及修改图层的字段
- 添加文本、自定义坐标轴、图例
- 添加图例
- python 绘图添加图例显示UserWarning: Legend does not support [<matplotlib.lines.Line2D object at 0x07FA3210>]
- matlab 画图添加图例时,改变图例中字体大小
- AE+C# 向axPageLayoutControl1添加图例
- ArcGIS Engine效率探究——要素的添加和删除、属性的读取和更新
- 在图形中添加一个图例
- ArcGIS Engine添加字段
- ArcGIS API for JavaScript 4.2学习笔记[10] 2D添加指北针widget、视图保存、视图padding(第二章完结)
- [ArcEngine地图制图系列]—添加地图指北针
- Python 添加图例出错:UserWarning: Legend does not support [<matplotlib.lines.Line2D object at 0x07FA3210>]
- ArcGIS Engine自定义工具类,实现添加图名,比例尺