📄 form03.frm
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "mo20.ocx"
Begin VB.Form Form03
Caption = "墨西哥地图"
ClientHeight = 5460
ClientLeft = 60
ClientTop = 345
ClientWidth = 7590
LinkTopic = "Form1"
ScaleHeight = 5460
ScaleWidth = 7590
StartUpPosition = 2 '屏幕中心
Begin MapObjects2.Map Map2
Height = 1215
Left = 120
TabIndex = 2
Top = 4080
Width = 1455
_Version = 131072
_ExtentX = 2566
_ExtentY = 2143
_StockProps = 225
BackColor = 16777215
BorderStyle = 1
Contents = "Form03.frx":0000
End
Begin VB.Frame Frame1
Caption = "Frame1"
Height = 3615
Left = 240
TabIndex = 1
Top = 120
Width = 1095
End
Begin MapObjects2.Map Map1
Height = 5175
Left = 1680
TabIndex = 0
Top = 120
Width = 5775
_Version = 131072
_ExtentX = 10186
_ExtentY = 9128
_StockProps = 225
BackColor = 16777215
BorderStyle = 1
Contents = "Form03.frx":001A
End
End
Attribute VB_Name = "Form03"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Xue Wei,2003/5/10
'用Form_Load、Map1_AfterLayerDraw、Map1_AfterLayerDraw过程来添加指示窗口;
'用Map1_MouseDown过程添加放大缩小功能,以检查指示窗口的连动功能;
'实现在Map2中拖动方框,改变Map1的功能;
Option Explicit
Dim g_feedback As DragFeedback
Private Sub Map2_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
'将点击转换为Map2上的点对象;
Dim p As Point
Set p = Map2.ToMapPoint(x, y)
'如果点击发生在方框内,开始拖动;
If Map1.Extent.IsPointIn(p) Then
Set g_feedback = New DragFeedback
g_feedback.DragStart Map1.Extent, Map2, x, y
End If
End Sub
'开始拖动方框
Private Sub Map2_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Not g_feedback Is Nothing Then
g_feedback.DragMove x, y
End If
End Sub
'拖动完成,并在Map1中显示新位置;
Private Sub Map2_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Not g_feedback Is Nothing Then
Map1.Extent = g_feedback.DragFinish(x, y)
Set g_feedback = Nothing
End If
End Sub
'左键放大,右键缩小;
Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim r As MapObjects2.Rectangle
If Button = vbLeftButton Then
Set Map1.Extent = Map1.TrackRectangle
ElseIf Button = vbRightButton Then
Set r = Map1.Extent
r.ScaleRectangle 2
Map1.Extent = r
End If
End Sub
'使Map2和Map1联动;
Private Sub Map1_AfterLayerDraw(ByVal index As Integer, ByVal canceled As Boolean, ByVal hdc As StdOle.OLE_HANDLE)
If index = 0 Then
Map2.TrackingLayer.Refresh True
End If
End Sub
'在Map2上画红色指示框;
Private Sub Map2_AfterTrackingLayerDraw(ByVal hdc As StdOle.OLE_HANDLE)
Dim sym As New Symbol
sym.OutlineColor = moRed
sym.Size = 2
sym.Style = moTransparentFill
Map2.DrawShape Map1.Extent, sym
End Sub
Private Sub Form_Load()
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("states")
layer.Symbol.Color = moPaleYellow
Map2.Layers.Add layer
Map2.Refresh
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -