form07b.frm
来自「给出了详细的vb环境下mo基本功能的代码 如图层的加载」· FRM 代码 · 共 136 行
FRM
136 行
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "mo20.ocx"
Begin VB.Form Form07b
Caption = "墨西哥地图"
ClientHeight = 6360
ClientLeft = 60
ClientTop = 345
ClientWidth = 8400
LinkTopic = "Form1"
ScaleHeight = 6360
ScaleWidth = 8400
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command4
Caption = "右"
Height = 495
Left = 6240
TabIndex = 4
Top = 5760
Width = 1215
End
Begin VB.CommandButton Command3
Caption = "左"
Height = 495
Left = 4440
TabIndex = 3
Top = 5760
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "下"
Height = 495
Left = 2640
TabIndex = 2
Top = 5760
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "上"
Height = 495
Left = 840
TabIndex = 1
Top = 5760
Width = 1335
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 = "form07b.frx":0000
End
End
Attribute VB_Name = "Form07b"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Xuewei,2003/5/7
'在墨西哥图上画矩形,可以上下左右移动;
Option Explicit
Dim Rect As MapObjects2.Rectangle
Dim Mul As Single
Private Sub Command1_Click()
Rect.Top = Rect.Top + Mul * 0.02
Rect.Bottom = Rect.Bottom + Mul * 0.02
Map1.Refresh
End Sub
Private Sub Command2_Click()
Rect.Top = Rect.Top - Mul * 0.02
Rect.Bottom = Rect.Bottom - Mul * 0.02
Map1.Refresh
End Sub
Private Sub Command3_Click()
Rect.Left = Rect.Left - Mul * 0.02
Rect.Right = Rect.Right - Mul * 0.02
Map1.Refresh
End Sub
Private Sub Command4_Click()
Rect.Left = Rect.Left + Mul * 0.02
Rect.Right = Rect.Right + Mul * 0.02
Map1.Refresh
End Sub
Private Sub Form_Load()
DrawLayer
Mul = 100
Set Rect = New MapObjects2.Rectangle
Rect.Top = Mul * 0.25 '离底部下边
Rect.Left = Mul * -1.1 '左边
Rect.Bottom = Mul * 0.28 '离底部上边
Rect.Right = Mul * -1.05 '右边
Map1.Refresh
End Sub
Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As stdole.OLE_HANDLE)
If Not Rect Is Nothing Then
Dim sym As New Symbol
sym.SymbolType = moFillSymbol
sym.Style = 9
sym.Size = 3
sym.Color = moRed
Map1.DrawShape Rect, sym
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
Map1.Layers.Add layer
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?