📄 form04.frm
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "mo20.ocx"
Begin VB.Form Form04
Caption = "墨西哥地图"
ClientHeight = 5400
ClientLeft = 60
ClientTop = 345
ClientWidth = 5070
LinkTopic = "Form1"
ScaleHeight = 5400
ScaleWidth = 5070
StartUpPosition = 3 '窗口缺省
Begin VB.ComboBox Combo3
Height = 300
Left = 120
TabIndex = 4
Text = "Combo3"
Top = 4920
Width = 2655
End
Begin VB.ComboBox Combo2
Height = 300
Left = 120
TabIndex = 3
Text = "Combo2"
Top = 4320
Width = 2655
End
Begin VB.ComboBox Combo1
Height = 300
Left = 120
TabIndex = 2
Text = "Combo1"
Top = 3720
Width = 2655
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 3240
TabIndex = 1
Top = 4200
Width = 1410
End
Begin MapObjects2.Map Map1
Height = 3375
Left = 0
TabIndex = 0
Top = 0
Width = 5055
_Version = 131072
_ExtentX = 8916
_ExtentY = 5953
_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/5/27
'通过设置单位、本初子午线、基准面,来定义一个自己的坐标系。
Option Explicit
Private Sub Command1_Click()
Dim theGcs As New MapObjects2.GeoCoordSys
Dim theUnit As New MapObjects2.Unit
Dim thePrime As New MapObjects2.PrimeMeridian
Dim theDatum As New MapObjects2.Datum
On Error GoTo Err1
theUnit.Type = Int(stripProjection(Combo1.List(Combo1.ListIndex)))
theGcs.Unit = theUnit
thePrime.Type = Int(stripProjection(Combo2.List(Combo2.ListIndex)))
theGcs.PrimeMeridian = thePrime
theDatum.Type = Int(stripProjection(Combo3.List(Combo3.ListIndex)))
theGcs.Datum = theDatum
Dim report As String
report = "地理坐标系" & theGcs.Name & "有:" & vbNewLine & _
"Units: " & theGcs.Unit.Name & vbNewLine & _
"PrimeMeridian: " & theGcs.PrimeMeridian.Name & vbNewLine & _
"Datum: " & theGcs.Datum.Name
MsgBox report, vbInformation, "自定义坐标系对象"
Exit Sub
Err1:
MsgBox "请选择Combo!"
End Sub
Private Sub Form_Load()
DrawLayer
Combo1.Text = "选择Unit..."
Combo2.Text = "选择Prime Meridian..."
Combo3.Text = "选择Datum..."
Command1.Caption = "自定义信息"
Dim str As New MapObjects2.Strings
Dim i As Integer
'向3个Combo中赋值;
str.PopulateWithUnits
For i = 0 To str.Count - 1
Combo1.AddItem str(i)
Next i
str.Clear
str.PopulateWithMeridians
For i = 0 To str.Count - 1
Combo2.AddItem str(i)
Next i
str.Clear
str.PopulateWithDatums
For i = 0 To str.Count - 1
Combo3.AddItem str(i)
Next i
End Sub
Private Function stripProjection(theProjection As String) As Double
'Strip the projection object type number from the selected string
Dim openB As Integer
openB = InStr(theProjection, "[")
stripProjection = CDbl(Left(Right(theProjection, Len(theProjection) - openB) _
, Len(theProjection) - openB - 1))
End Function
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 = moLimeGreen
Map1.Layers.Add layer
Set layer = New MapLayer
Set layer.GeoDataset = dc.FindGeoDataset("cities")
layer.Symbol.Color = moRed
Map1.Layers.Add layer
Set layer = New MapLayer
Set layer.GeoDataset = dc.FindGeoDataset("rivers")
layer.Symbol.Color = moBlue
Map1.Layers.Add layer
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -