⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form02.frm

📁 给出了详细的vb环境下mo基本功能的代码 如图层的加载
💻 FRM
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "mo20.ocx"
Begin VB.Form Form02 
   Caption         =   "墨西哥地图"
   ClientHeight    =   6180
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8625
   LinkTopic       =   "Form1"
   ScaleHeight     =   6180
   ScaleWidth      =   8625
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Command6 
      Caption         =   "显示地图"
      Height          =   375
      Left            =   7080
      TabIndex        =   6
      Top             =   5640
      Width           =   1215
   End
   Begin VB.CommandButton Command5 
      Caption         =   "隐藏地图"
      Height          =   375
      Left            =   5640
      TabIndex        =   5
      Top             =   5640
      Width           =   1215
   End
   Begin VB.CommandButton Command4 
      Caption         =   "图层0可见"
      Height          =   375
      Left            =   4200
      TabIndex        =   4
      Top             =   5640
      Width           =   1215
   End
   Begin VB.CommandButton Command3 
      Caption         =   "图层0不可见"
      Height          =   375
      Left            =   2760
      TabIndex        =   3
      Top             =   5640
      Width           =   1215
   End
   Begin VB.CommandButton Command2 
      Caption         =   "图层卸载"
      Height          =   375
      Left            =   1560
      TabIndex        =   2
      Top             =   5640
      Width           =   975
   End
   Begin VB.CommandButton Command1 
      Caption         =   "图层加载"
      Height          =   375
      Left            =   360
      TabIndex        =   1
      Top             =   5640
      Width           =   975
   End
   Begin MapObjects2.Map Map1 
      Height          =   5415
      Left            =   120
      TabIndex        =   0
      Top             =   0
      Width           =   8415
      _Version        =   131072
      _ExtentX        =   14843
      _ExtentY        =   9551
      _StockProps     =   225
      BackColor       =   16777215
      BorderStyle     =   1
      Contents        =   "Form02.frx":0000
   End
End
Attribute VB_Name = "Form02"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Xue Wei,2003/5/3
'用程序加载和卸载图层,隐藏图层和Map1。

Option Explicit
Dim dc As New DataConnection
Dim layer As MapLayer

Private Sub Command1_Click()
  LayerSet
  Map1.Refresh
End Sub

Private Sub Command2_Click()
  Map1.Layers.Clear   '清除Map1的所有图层。
End Sub

Private Sub Command3_Click()
  On Error GoTo err1    '如果Map1已经被清除,不进行操作。
  Set layer = Map1.Layers(0)
  layer.Visible = False
  Map1.Refresh
  Exit Sub
err1:
  MsgBox "没有图层!"
End Sub

Private Sub Command4_Click()
  On Error GoTo err1    '如果Map1已经被清除,不进行操作。
  Set layer = Map1.Layers(0)
  layer.Visible = True
  Map1.Refresh
  Exit Sub
err1:
  MsgBox "没有图层!"
End Sub

Private Sub Command5_Click()
  Map1.Visible = False
End Sub

Private Sub Command6_Click()
  Map1.Visible = True
End Sub

Private Sub LayerSet()    '图层设置模块
  Set layer = New MapLayer
  Set layer.GeoDataset = dc.FindGeoDataset("States")
  Map1.Layers.Add layer
  Set layer = New MapLayer
  Set layer.GeoDataset = dc.FindGeoDataset("Rivers")
  Map1.Layers.Add layer
End Sub

Private Sub Form_Load()
  dc.Database = App.Path
  If Not dc.Connect Then
    MsgBox "在指定的文件夹下没找到图层数据文件!"
    End
  End If
  
  LayerSet
  Map1.Refresh
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -