欢迎您来到GIS动力

加入收藏 免费注册 用户登陆 帮助中心
首页 新闻动态 技术专栏 银杏树下 学习考研 软件下载 求职招聘 许愿瓶 节日祝福 用户中心 精彩推荐 资源搜索 地图
专栏导航: AO开发 | SO开发 | ArcGIS桌面 | 超图桌面 | 开发语言 | 数据库 | WebGIS | 银杏文学 | 研究生考题 | FreeMap 谈天说地
   您现在位于: 首页技术专栏ArcGIS应用与开发AO开发 → 正文
AO里面的MapGrid对象模型
07-11-08 10:43:27 作者:jbttm 出处:浩淼的天空

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的,还没有转到控件上使用。 


(本文已被浏览 次)
发布人:admin
推荐给好友:发送给好友
上篇新闻:
下篇新闻:
相关评论
发表我的评论
  • 尊重网上道德,遵守《全国人大常委会关于维护互联网安全的决定》及中华人民共和国其他各项有关法律法;
  • 本站有权保留或删除您发表的任何评论内容;
  •   相关文章  

    关于我们 友情链接 ┋ 与我在线 ┋ 管理 ┋ TOP
    网站当前版本:GisPower CMS V3.0
    『GIS 动力』- http://www.gispower.org/
    联系我们:webmaster#gispower.org
    Copyright (c) 2003-2007 GisPOwer.Org. All Rights Reserved.

                   滇ICP备05006901号