📄 form1.frm
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "Mo20.ocx"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 5580
ClientLeft = 60
ClientTop = 450
ClientWidth = 7665
LinkTopic = "Form1"
ScaleHeight = 5580
ScaleWidth = 7665
StartUpPosition = 3 '窗口缺省
Begin MapObjects2.Map Map2
Height = 1575
Left = 120
TabIndex = 1
Top = 3360
Width = 1815
_Version = 131072
_ExtentX = 3201
_ExtentY = 2778
_StockProps = 225
BackColor = 16777215
BorderStyle = 1
Contents = "Form1.frx":0000
End
Begin MapObjects2.Map Map1
Height = 3975
Left = 2280
TabIndex = 0
Top = 960
Width = 4575
_Version = 131072
_ExtentX = 8070
_ExtentY = 7011
_StockProps = 225
BackColor = 16777215
BorderStyle = 1
Contents = "Form1.frx":001A
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
Dim layer As MapLayer
Dim dc As New DataConnection
dc.Database = App.Path
Set layer = New MapLayer
Set layer.GeoDataset = dc.FindGeoDataset("states")
layer.Symbol.Color = moYellow
layer.Symbol.Size = 1
layer.Symbol.OutlineColor = moBrown
layer.Symbol.SymbolType = moLineSymbol
layer.Name = "行政区"
Map1.Layers.Add layer
Set layer = New MapLayer
Set layer.GeoDataset = dc.FindGeoDataset("rivers")
layer.Symbol.Size = 2
layer.Symbol.Color = moDarkGreen
layer.Name = "河流"
Set layer = New MapLayer
Set layer.GeoDataset = dc.FindGeoDataset("cities")
layer.Symbol.Size = 3
layer.Symbol.Color = moRed
layer.Symbol.Style = 0
layer.Name = "城市"
Set layer = New MapLayer
layer.Name = "城市名称"
layer.Symbol.Size = 0
Set layer.Renderer = New LabelRenderer
layer.Renderer.Field = "NAME "
layer.Renderer.Symbol(0).Font.Name = "幼圆"
layer.Renderer.Symbol(0).Color = moBlack
layer.Renderer.Symbol(0).Font.Size = 9
layer.Renderer.AllowDuplicates = True
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
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
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 1.5
Map1.Extent = r
End If
End Sub
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 Map2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim curRectangle As MapObjects2.Rectangle
Dim pt As New MapObjects2.Point
Set curRectangle = Map2.TrackRectangle
Set Map1.Extent = curRectangle
Set pt = Map2.ToMapPoint(X, Y)
Map1.CenterAt pt.X, pt.Y
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -