📄 form01.frm
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "mo20.ocx"
Begin VB.Form Form01
Caption = "世界地图"
ClientHeight = 4260
ClientLeft = 60
ClientTop = 345
ClientWidth = 6465
LinkTopic = "Form1"
ScaleHeight = 4260
ScaleWidth = 6465
StartUpPosition = 2 '屏幕中心
Begin VB.ListBox List1
Height = 2040
Left = 4680
TabIndex = 3
Top = 360
Width = 1575
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 4800
TabIndex = 2
Top = 2760
Width = 1335
End
Begin MapObjects2.Map Map1
Height = 3375
Left = 120
TabIndex = 0
Top = 120
Width = 4335
_Version = 131072
_ExtentX = 7646
_ExtentY = 5953
_StockProps = 225
BackColor = 16777215
BorderStyle = 1
Contents = "Form01.frx":0000
End
Begin VB.Label Label1
Caption = "Label1"
Height = 255
Left = 1560
TabIndex = 1
Top = 3720
Width = 3735
End
End
Attribute VB_Name = "Form01"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Xue Wei,2003/6/10
'设置Unit演示;
Option Explicit
Dim theUnit As New MapObjects2.Unit
Private Sub Command1_Click()
Label1.Caption = "图层的单位:" & theUnit.Name
End Sub
Private Sub Form_Load()
Dim unitObjs As New MapObjects2.Strings
Dim i As Integer
'加载世界地图中的Country图层;
DrawLayer
'得到所有Unit常数名的集合;
unitObjs.PopulateWithUnits
'找到单位变量
With Map1.Layers(0).CoordinateSystem
If .IsProjected Then
Set theUnit = .GeoCoordSys.Unit
Else
Set theUnit = .Unit
End If
End With
'给List1赋值;
For i = 0 To unitObjs.Count - 1
List1.AddItem unitObjs(i) 'theUnit.Name
Next i
Command1.Caption = "显示"
Label1.Caption = "点击“显示”显示单位。"
End Sub
Private Sub List1_Click()
Dim Str1 As String
Str1 = List1.List(List1.ListIndex)
theUnit.Type = Int(stripProjection(Str1))
End Sub
Private Function stripProjection(theProjection As String) As Double
Dim openB As Integer
openB = InStr(theProjection, "[")
stripProjection = CDbl(Left(Right(theProjection, Len(theProjection) - openB) _
, Len(theProjection) - openB - 1))
End Function
Sub DrawLayer()
Dim dc As New DataConnection
Dim layer As MapLayer
dc.Database = App.Path + "\..\" + "world"
If Not dc.Connect Then
MsgBox "在指定的文件夹下没找到图层数据文件!"
End
End If
Set layer = New MapLayer
Set layer.GeoDataset = dc.FindGeoDataset("country")
layer.Symbol.Color = moLimeGreen
Map1.Layers.Add layer
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -