📄 identify.frm
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "mo20.ocx"
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Begin VB.Form Form1
Caption = "SearchByDistance方法事例"
ClientHeight = 3330
ClientLeft = 1095
ClientTop = 1515
ClientWidth = 8160
LinkTopic = "Form1"
PaletteMode = 1 'UseZOrder
ScaleHeight = 3330
ScaleWidth = 8160
Begin ComctlLib.ListView ListView1
Height = 3135
Left = 5040
TabIndex = 0
Top = 120
Width = 3015
_ExtentX = 5318
_ExtentY = 5530
View = 3
LabelWrap = -1 'True
HideSelection = -1 'True
_Version = 327682
ForeColor = -2147483640
BackColor = -2147483643
Appearance = 1
NumItems = 0
End
Begin MapObjects2.Map Map1
Height = 3135
Left = 120
TabIndex = 1
Top = 120
Width = 4815
_Version = 131072
_ExtentX = 8493
_ExtentY = 5530
_StockProps = 225
BackColor = 16777215
BorderStyle = 1
Contents = "Identify.frx":0000
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()
'初始化ListView的列首
Set Col = ListView1.ColumnHeaders.Add()
Col.Text = "字段"
Set Col = ListView1.ColumnHeaders.Add()
Col.Text = "值"
'调入MapObjects自带的World数据
'默认路径为C:\Program Files\ESRI\MapObjects2\Samples\Data\World
Dim dc As New DataConnection
dc.Database = "C:\Program Files\ESRI\MapObjects2\Samples\Data\World"
If Not dc.Connect Then End
Dim layer As MapLayer
'调入country.shp图层
Set layer = New MapLayer
Set layer.GeoDataset = dc.FindGeoDataset("country")
layer.Symbol.Color = moYellow
Map1.Layers.Add layer
End Sub
'Map Control中鼠标按键按下响应代码
Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
'得到Country图层
Set l = Map1.Layers("country")
'将坐标转换到地图坐标系下的坐标
Set p = Map1.ToMapPoint(x, y)
'执行SearchByDistance方法,获取p点附近的地理对象数据
Set recs = l.SearchByDistance(p, 1, "")
'若找到地理对象,则返回其记录集
If Not recs.EOF Then
'清除ListView中已有的数据
ListView1.ListItems.Clear
'遍历Fields集合,获取所有字段的值
For Each fld In recs.Fields
Set newItem = ListView1.ListItems.Add
newItem.Text = fld.Name
newItem.SubItems(1) = fld.ValueAsString
Next fld
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -