form04.frm

来自「一个关于基于MO编程的参考资料希望对大家的交流和学习有帮助」· FRM 代码 · 共 124 行

FRM
124
字号
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "mo20.ocx"
Begin VB.Form Form04 
   Caption         =   "墨西哥地图"
   ClientHeight    =   6405
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8310
   LinkTopic       =   "Form2"
   ScaleHeight     =   6405
   ScaleWidth      =   8310
   StartUpPosition =   1  '所有者中心
   Begin VB.Timer Timer1 
      Interval        =   10
      Left            =   3600
      Top             =   3000
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   495
      Left            =   4320
      TabIndex        =   1
      Top             =   5880
      Width           =   1215
   End
   Begin MapObjects2.Map Map1 
      Height          =   5655
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   8055
      _Version        =   131072
      _ExtentX        =   14208
      _ExtentY        =   9975
      _StockProps     =   225
      BackColor       =   16777215
      BorderStyle     =   1
      Contents        =   "Form04.frx":0000
   End
End
Attribute VB_Name = "Form04"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Xuewei,2003/6/4
'Move练习;

Option Explicit

Private 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 = moPaleYellow
  Map1.Layers.Add layer
  
  Set layer = New MapLayer
  Set layer.GeoDataset = dc.FindGeoDataset("Rivers")
  layer.Symbol.Color = moDarkGreen
  Map1.Layers.Add layer
End Sub

Private Sub Command1_Click()
  Dim rx As Single
  Dim ry As Single
  Dim i As Integer, j As Integer
  Dim Ent As Integer
  Const Dx = 1
  Const Dy = 1
  
  Ent = Map1.TrackingLayer.EventCount
  If Ent = 0 Then
    MsgBox "请点击地图!"
    Exit Sub
  End If
  For i = 1 To 50
    For j = 1 To Ent
    rx = 2 * Rnd - 1
    ry = 2 * Rnd - 1
    Map1.TrackingLayer.Event(j - 1).Move rx * Dx, ry * Dy
    Delay (Int(100 / Ent))
    Map1.TrackingLayer.Refresh True
    Next j
  Next i
End Sub

Private Sub Form_Load()
  DrawLayer
  Command1.Caption = "Move"
  With Map1.TrackingLayer.Symbol(0)
    .SymbolType = moPointSymbol
    .Font = "ESRI Transportation & Municipal"
    .Size = 15
    .Style = moTrueTypeMarker
    .Color = moRed
  End With
End Sub

Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  Dim oPoint As MapObjects2.Point
  Set oPoint = Map1.ToMapPoint(x, y)
  Map1.TrackingLayer.Symbol(0).CharacterIndex = 101
  Map1.TrackingLayer.AddEvent oPoint, 0

End Sub

Sub Delay(ss As Integer)    '延时过程
  Dim start, check
  start = Timer
  Do
    check = Timer
  Loop While check < start + ss * 0.001
End Sub


⌨️ 快捷键说明

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