http://www.gissky.net- GIS空间站

我要投稿 投稿指南 RSS订阅 网站资讯通告:
搜索: 您现在的位置: GIS空间站 >> 技术专栏 >> ArcGIS >> ArcObjects开发 >> 正文

浩淼的天空:AO里面的MapGrid对象模型

作者:浩淼的天…    文章来源:http://www.hmgis.cn    点击数:    更新时间:2007-1-27
摘要:

mapgrid也就是所谓的地图网格,它必须存在layout视图而不会在map视图中出现,在mapgrid模型里面,主要有四个内容:
1.mapgrid及其子类,其子类都是coclass,可以创建
2.mapgrid的border类,创建网格的边缘
3.mapgrid的label类,创建边缘的标签
4.mapgridfactory,它可以依据默认的属性快速创建一个mapgrid


在arcmap里面,看起来map和pagelayout都是视图的一种,map管理layer,而pagelayout管理layout,但是实
际上,map与pagelayout都实现了iactiveview和igraphicscontainer接口,但是实际上是pagelayout管理
着mapframe,mapsurroundframe和elementframe,其中mapframe管理了map和mapgrid对象。
mapsurroundframe管理了指北针,legend,mapinset等对象.


下面是一个mapgrid的例子:

Sub MapGrid()

    '找到当前所使用的MapFrame
    Dim pMxDoc As
IMxDocument
    Dim pMap As IMap
    Dim pGrahpicsContainer As
IGraphicsContainer
    Dim pMapFrame As IMapFrame
   
    Set pMxDoc =
ThisDocument
    Set pMap = pMxDoc.FocusMap
    Set pGrahpicsContainer =
pMxDoc.PageLayout
    Set pMapFrame =
pGrahpicsContainer.FindFrame(pMap)
   
   
'生成一个Mapgrid对象,生成最简单的graticule网格
    Dim pMapGrid As IMapGrid
    Dim
pMeasuredGrid As IMeasuredGrid
    Set pMeasuredGrid = New Graticule
   
Set pMapGrid = pMeasuredGrid
   
    pMeasuredGrid.FixedOrigin =
True
    pMeasuredGrid.XIntervalSize = 10
    pMeasuredGrid.XOrigin =
-180
    pMeasuredGrid.YIntervalSize = 10
    pMeasuredGrid.YOrigin =
-90
   
    '生成mapgrid的border
    Dim pCalibrateBorder As
ICalibratedMapGridBorder
    Set pCalibrateBorder = New
CalibratedMapGridBorder
    Dim pBackColor As IColor
    Dim pForeColor As
IColor
    Set pBackColor = New RgbColor
    Set pForeColor = New
RgbColor
    pBackColor.RGB = RGB(255, 255, 0)
    pForeColor.RGB = RGB(0,
255, 0)
    pCalibrateBorder.BackgroundColor = pBackColor
   
pCalibrateBorder.ForegroundColor = pForeColor
   
pCalibrateBorder.Alternating = True
    pCalibrateBorder.BorderWidth =
10
    pCalibrateBorder.Interval = 72
   
    '生成mapgrid的label
   
Dim pFormattedGridLabel As IFormattedGridLabel
    Set pFormattedGridLabel =
New FormattedGridLabel
    Dim pNumericFormat As INumericFormat
    Set
pNumericFormat = New NumericFormat
    pNumericFormat.AlignmentOption =
esriAlignLeft
    pNumericFormat.RoundingOption =
esriRoundNumberOfDecimals
    pNumericFormat.RoundingValue = 2
   
pNumericFormat.ShowPlusSign = False
    pNumericFormat.UseSeparator =
True
    pNumericFormat.ZeroPad = True
    pFormattedGridLabel.Format =
pNumericFormat
    
    '添加属性到mapgrid里面
    pMapGrid.Border =
pCalibrateBorder
    pMapGrid.LabelFormat = pFormattedGridLabel
   
'把这个Grid添加进地图里面,注意是MAPframe在管理
    Dim pMapGrids As IMapGrids
    Set
pMapGrids = pMapFrame
   
    Dim pActiveView As IActiveView
    Set
pActiveView = pMxDoc.PageLayout
   
    pMapGrids.AddMapGrid
pMapGrid
    pActiveView.PartialRefresh esriViewBackground, Nothing,
Nothing
   
End Sub

这段代码是VBA的,还没有转到控件上使用。 

Tags:ArcGIS MapGrid对象  
责任编辑:gissky
相关文章列表
没有相关文章
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 中国地图