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

📄 form03.frm

📁 给出了详细的vb环境下mo基本功能的代码 如图层的加载
💻 FRM
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "mo20.ocx"
Begin VB.Form Form03 
   Caption         =   "form1"
   ClientHeight    =   6360
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8400
   LinkTopic       =   "Form1"
   ScaleHeight     =   6360
   ScaleWidth      =   8400
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   495
      Left            =   3600
      TabIndex        =   1
      Top             =   5760
      Width           =   1215
   End
   Begin MapObjects2.Map Map1 
      Height          =   5655
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   8415
      _Version        =   131072
      _ExtentX        =   14843
      _ExtentY        =   9975
      _StockProps     =   225
      BackColor       =   16777215
      BorderStyle     =   1
      Contents        =   "form03.frx":0000
   End
End
Attribute VB_Name = "Form03"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Xuewei,2003/6/27
'求点到点的距离;

Option Explicit
Dim oPoint1 As MapObjects2.Point
Dim oPoint2 As MapObjects2.Point

Private Sub Command1_Click()
  Set oPoint1 = Map1.Extent.Center
  Map1.Refresh
End Sub

Private Sub Form_Load()
  DrawLayer     '加载墨西哥地图;
  Command1.Caption = "显示点"
  Me.Caption = "计算点到点的距离"
End Sub

Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As stdole.OLE_HANDLE)
  Dim Sym1 As New MapObjects2.Symbol
  Dim Sym2 As New MapObjects2.Symbol
  
  If Not oPoint1 Is Nothing Then
    Sym1.SymbolType = moPointSymbol
    Sym1.Color = moRed
    Sym1.Size = 10
    Sym1.Style = 0
    Map1.DrawShape oPoint1, Sym1
  End If
  
  If Not oPoint2 Is Nothing Then
    Sym2.SymbolType = moPointSymbol
    Sym2.Color = moBlue
    Sym2.Size = 9
    Sym2.Style = 2
    Map1.DrawShape oPoint2, Sym2
  End If
End Sub

Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  Dim fDist As Double
  If oPoint1 Is Nothing Then
    MsgBox "先单击“显示点”"
    Exit Sub
  Else
    Set oPoint2 = Map1.ToMapPoint(x, y)
    fDist = oPoint2.DistanceTo(oPoint1)
    Map1.TrackingLayer.Refresh True
    MsgBox "距离=" & Format(fDist, "fixed")
  End If
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 = moLimeGreen
  Map1.Layers.Add layer
End Sub

⌨️ 快捷键说明

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