默认头像
路人甲
路人甲
  • 注册日期2004-09-02
  • 发帖数72
  • QQ
  • 铜币387枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1567回复:1

加载和保存当前MapControl中的视图?

楼主#
更多 发布于:2005-05-08 16:01

以下代码只能实现保存当前pagelayout中的内容,

请问:怎么样实现保存mapcontrol中的内容

我分析的原因是:frmMap.MapMain.LoadMxFile sFilePath,而pagelayout中的内容是

Set frmMap.MainLayout.PageLayout = m_pMapDocument.PageLayout

通过接口IMapDocument实现,所以现在的方法是怎么样通过IMapDocument接口加载到MapMain中

这种方法有问题:Set frmMap.MapMain.Map=m_pMapDocument.Map(0)

请问有谁知道其他的方法,告知感谢!

MapMain为Mapcontrol控件

MapLayout为PageLayout控件

Private m_pMapDocument As IMapDocument

Private Sub OpenDoc()          CommonDialog1.DialogTitle = "浏览Map文档"     CommonDialog1.Filter = "Map Documents (*.mxd)|*.mxd"     CommonDialog1.ShowOpen               Dim sFilePath As String     sFilePath = CommonDialog1.FileName     If sFilePath = "" Then Exit Sub     Set m_pMapDocument = New MapDocument

    '验证并载入MXD文件     If frmMap.MapMain.CheckMxFile(sFilePath) Then

        frmMap.MapMain.MousePointer = esriPointerHourglass         m_pMapDocument.Open sFilePath

       Set frmMap.MainLayout.PageLayout = m_pMapDocument.PageLayout         frmMap.MapMain.LoadMxFile sFilePath

       '保持map上的视图区域与doc上的一致                Dim pActiveView As IActiveView         Set pActiveView = frmMap.MapMain.ActiveView         Set pActiveView = m_pMapDocument.ActiveView

'         frmMap.MapMain.MousePointer = esriPointerDefault              Else         MsgBox sFilePath ; " 不是有效的文件"     End If End Sub

Private Sub SaveDoc()          '判断只读的情况     If m_pMapDocument.IsReadOnly(m_pMapDocument.DocumentFilename) = True Then         MsgBox "This map document is read only!", , "Save Failed"         Exit Sub     End If     '存盘     m_pMapDocument.Save m_pMapDocument.UsesRelativePaths     MsgBox "存盘成功!", , "Saved Document"      End Sub

喜欢0 评分0
http://www.geostar.com.cn(吉奥 公司) http://www.waterblue.com.cn(水之灵,蓝之静 个人)
默认头像
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2005-05-08 18:15
调用toolbarcontrol的命令也ok的
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
默认头像

返回顶部