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

📄 form07.frm

📁 给出了详细的vb环境下mo基本功能的代码 如图层的加载
💻 FRM
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "mo20.ocx"
Object = "{6C20C089-0689-11D5-B2F8-000102D87123}#2.0#0"; "MO21ScaleBar.ocx"
Begin VB.Form Form07 
   Caption         =   "墨西哥地图"
   ClientHeight    =   4710
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8115
   LinkTopic       =   "Form1"
   ScaleHeight     =   4710
   ScaleWidth      =   8115
   StartUpPosition =   2  '屏幕中心
   Begin VB.Frame Frame1 
      Caption         =   "Frame1"
      Height          =   3375
      Left            =   240
      TabIndex        =   1
      Top             =   240
      Width           =   1695
   End
   Begin MapObjects2.Map Map1 
      Height          =   4455
      Left            =   2280
      TabIndex        =   0
      Top             =   120
      Width           =   5775
      _Version        =   131072
      _ExtentX        =   10186
      _ExtentY        =   7858
      _StockProps     =   225
      BackColor       =   16777215
      BorderStyle     =   1
      Contents        =   "Form07.frx":0000
   End
   Begin MO21ScaleBar.ScaleBar sbScaleBar1 
      Height          =   735
      Left            =   0
      TabIndex        =   2
      Top             =   3840
      Width           =   2055
      _ExtentX        =   3625
      _ExtentY        =   1296
      BackColor       =   -2147483633
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ScaleText       =   1
      ScaleBarUnits   =   3
      ScreenUnits     =   1
   End
End
Attribute VB_Name = "Form07"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Xue Wei,2003/5/13
'添加ScaleBar控件

Option Explicit

Private Sub refreshScale()
 sbScaleBar1.MapExtent.MaxX = Map1.Extent.Right
 sbScaleBar1.MapExtent.MinX = Map1.Extent.Left
 sbScaleBar1.MapExtent.MaxY = Map1.Extent.Bottom
 sbScaleBar1.MapExtent.MinY = Map1.Extent.Top
   
 sbScaleBar1.PageExtent.MinX = Map1.Left / Screen.TwipsPerPixelX
 sbScaleBar1.PageExtent.MinY = Map1.Top / Screen.TwipsPerPixelY
 sbScaleBar1.PageExtent.MaxX = (Map1.Left + Map1.Width) / Screen.TwipsPerPixelX
 sbScaleBar1.PageExtent.MaxY = (Map1.Top + Map1.Height) / Screen.TwipsPerPixelY
 
 sbScaleBar1.Refresh
End Sub

Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  If Button = vbLeftButton Then
    Set Map1.Extent = Map1.TrackRectangle
  ElseIf Button = vbRightButton Then
    Map1.Pan
  End If
End Sub

Private Sub Map1_AfterLayerDraw(ByVal Index As Integer, ByVal canceled As Boolean, ByVal hdc As stdole.OLE_HANDLE)
  Call refreshScale
End Sub

Sub DrawLayer()
  Dim dc As New DataConnection
  Dim layer As MapLayer
  dc.Database = App.Path + "\..\" + "Mexico"
  If Not dc.Connect Then
    MsgBox "在指定的文件夹下没找到图层数据文件!"
    End
  End If
  
  Set layer = New MapLayer
  Set layer.GeoDataset = dc.FindGeoDataset("States")
  layer.Symbol.Color = moYellow
  Map1.Layers.Add layer
  
  Set layer = New MapLayer
  Set layer.GeoDataset = dc.FindGeoDataset("Rivers")
  layer.Symbol.Color = moRed
  Map1.Layers.Add layer
  Map1.Refresh
  
  Set layer = New MapLayer
  Set layer.GeoDataset = dc.FindGeoDataset("Cities")
  layer.Symbol.Color = moBlue
  Map1.Layers.Add layer
End Sub

Private Sub Form_Load()
  DrawLayer
End Sub

⌨️ 快捷键说明

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