📄 form04.frm
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "mo20.ocx"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form Form04
Caption = "墨西哥地图"
ClientHeight = 6645
ClientLeft = 60
ClientTop = 345
ClientWidth = 6630
LinkTopic = "Form1"
ScaleHeight = 6645
ScaleWidth = 6630
StartUpPosition = 2 '屏幕中心
Begin MSComctlLib.ListView ListView1
Height = 1335
Left = 1440
TabIndex = 1
Top = 5040
Width = 3495
_ExtentX = 6165
_ExtentY = 2355
View = 3
LabelWrap = -1 'True
HideSelection = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 0
End
Begin MapObjects2.Map Map1
Height = 4575
Left = 120
TabIndex = 0
Top = 120
Width = 6375
_Version = 131072
_ExtentX = 11245
_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/5/13
'用ListView添加属性窗口;
Option Explicit
Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim ly1 As MapObjects2.MapLayer
Dim fld As MapObjects2.Field
Dim newItem As Object
Dim p As MapObjects2.Point
Dim Recs As MapObjects2.Recordset
Set ly1 = Map1.Layers("States")
Set p = Map1.ToMapPoint(x, y)
Set Recs = ly1.SearchShape(p, moPointInPolygon, "")
If Not Recs.EOF Then
ListView1.ListItems.Clear
For Each fld In Recs.Fields ' iterate over the fields
Set newItem = ListView1.ListItems.Add
newItem.Text = fld.Name
newItem.SubItems(1) = fld.ValueAsString ' get the value
Next fld
End If
End Sub
Private Sub Form_Load()
Dim col As Object
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 col = ListView1.ColumnHeaders.Add()
col.Text = "属性名称"
Set col = ListView1.ColumnHeaders.Add()
col.Text = "属性值"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -