📄 form04.frm
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "mo20.ocx"
Begin VB.Form Form04
Caption = "墨西哥地图"
ClientHeight = 5355
ClientLeft = 60
ClientTop = 345
ClientWidth = 6765
LinkTopic = "Form1"
ScaleHeight = 5355
ScaleWidth = 6765
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command1
Caption = "显示"
Height = 495
Left = 2760
TabIndex = 1
Top = 4800
Width = 1335
End
Begin MapObjects2.Map Map1
Height = 4575
Left = 0
TabIndex = 0
Top = 0
Width = 6735
_Version = 131072
_ExtentX = 11880
_ExtentY = 8070
_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
'Xue Wei,2003/6/6
'使用ValueRenderer;
Option Explicit
Dim moRecset As MapObjects2.Recordset
Dim oRenderer As New MapObjects2.ValueMapRenderer
Private Sub Command1_Click()
Dim strs As New MapObjects2.Strings
Dim sFldname As String
Dim oSym As New MapObjects2.Symbol
Dim i As Integer
'初始化
Set moRecset = Map1.Layers(0).Records
sFldname = "AREA"
Do While Not moRecset.EOF
strs.Add moRecset(sFldname).ValueAsString
moRecset.MoveNext
Loop
'设置渲染参数;
Set Map1.Layers(0).Renderer = oRenderer
oRenderer.Field = sFldname
oRenderer.ValueCount = strs.Count '- 3
'设置缺省值
oRenderer.UseDefault = True
Set oSym = oRenderer.DefaultSymbol
oSym.Color = moPaleYellow
'开始渲染;
For i = 0 To oRenderer.ValueCount - 1
oRenderer.Value(i) = strs(i)
Next i
Map1.Refresh
'清除对象,为下次点击准备;
Set oRenderer = Nothing
Set strs = Nothing
Set moRecset = Nothing
End Sub
Private Sub Form_Load()
DrawLayer '添加一个States图层;
End Sub
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 = moOrange
layer.Symbol.Size = 1
layer.Symbol.Style = 2
layer.Symbol.OutlineColor = moBrown
Map1.Layers.Add layer
Map1.Refresh
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -