我是靠谱客的博主 诚心电灯胆,最近开发中收集的这篇文章主要介绍arcgis engine - 添加图例,指北针.,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

esri帮助提供了使用比例尺的方法: Working with map surrounds

主要代码为:

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

转载于:https://www.cnblogs.com/listened/p/4233668.html

最后

以上就是诚心电灯胆为你收集整理的arcgis engine - 添加图例,指北针.的全部内容,希望文章能够帮你解决arcgis engine - 添加图例,指北针.所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(87)

评论列表共有 0 条评论

立即
投稿
返回
顶部