Engine中如何绘制经纬网格线?

Engine中如何绘制经纬网格线?
已邀请:

刘峥 - ArcGIS多面手

赞同来自:

【解决办法】:

public void CreateGrid(IActiveView activeView, IPageLayout pageLayout) 

//Create the grid. 
IMapGrid mapGrid = new GraticuleClass(); 
mapGrid.Name = Map Grid; 

//Create a color. 
IColor color = new RgbColorClass(); 
color.RGB = 0XBBBBBB; // -> Gray. 

//Set the line symbol used to draw the grid. 
ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass 
(); 
cartographicLineSymbol.Cap = esriLineCapStyle.esriLCSButt; 
cartographicLineSymbol.Width = 2; 
cartographicLineSymbol.Color = color; 
mapGrid.LineSymbol = cartographicLineSymbol as ILineSymbol; 
mapGrid.Border = null; // Clear the default frame border. 

//Set the Tick properties. 
mapGrid.TickLength = 15; 
cartographicLineSymbol = new CartographicLineSymbolClass(); 
cartographicLineSymbol.Cap = esriLineCapStyle.esriLCSButt; 
cartographicLineSymbol.Width = 1; 
cartographicLineSymbol.Color = color; 
mapGrid.TickLineSymbol = cartographicLineSymbol as ILineSymbol; 
mapGrid.TickMarkSymbol = null; 

//Set the SubTick properties. 
mapGrid.SubTickCount = 5; 
mapGrid.SubTickLength = 10; 
cartographicLineSymbol = new CartographicLineSymbolClass(); 
cartographicLineSymbol.Cap = esriLineCapStyle.esriLCSButt; 
cartographicLineSymbol.Width = 0.2; 
cartographicLineSymbol.Color = color; 
mapGrid.SubTickLineSymbol = cartographicLineSymbol as ILineSymbol; 

// Set the Grid label properties. 
IGridLabel gridLabel = mapGrid.LabelFormat; 
gridLabel.LabelOffset = 15; 

//Set the Tick, SubTick, and Label Visibility along the four sides of the grid. 
mapGrid.SetTickVisibility(true, true, true, true); 
mapGrid.SetSubTickVisibility(true, true, true, true); 
mapGrid.SetLabelVisibility(true, true, true, true); 

//Make the map grid visible so it gets drawn when Active View is updated. 
mapGrid.Visible = true; 

//Set the IMeasuredGrid properties. 
IMeasuredGrid measuredGrid = mapGrid as IMeasuredGrid; 
measuredGrid.FixedOrigin = true; 
measuredGrid.XIntervalSize = 10; //Meridian interval. 
measuredGrid.XOrigin = 5; //Shift grid 5°. 
measuredGrid.YIntervalSize = 10; //Parallel interval. 
measuredGrid.YOrigin = 5; //Shift grid 5°. 

// Add the grid to the MapFrame. 
IMap map = activeView.FocusMap; 
IGraphicsContainer graphicsContainer = pageLayout as IGraphicsContainer; 
IFrameElement frameElement = graphicsContainer.FindFrame(map); 
IMapFrame mapFrame = frameElement as IMapFrame; 
IMapGrids mapGrids = null; 
mapGrids = mapFrame as IMapGrids; 
mapGrids.AddMapGrid(mapGrid); 

//Refresh the view. 
activeView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null); 


参考帮助文档:http://help.arcgis.com/en/sdk/ ... 00000 ​

要回复问题请先登录注册