📄 form05.frm
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "Mo20.ocx"
Begin VB.Form Form05
Caption = "查找指定范围内的特征"
ClientHeight = 6735
ClientLeft = 60
ClientTop = 345
ClientWidth = 7710
LinkTopic = "Form1"
ScaleHeight = 6735
ScaleWidth = 7710
StartUpPosition = 2 'CenterScreen
Begin VB.ComboBox Combo1
Height = 300
Left = 4560
TabIndex = 2
Text = "Combo1"
Top = 5760
Width = 1335
End
Begin MapObjects2.Map Map1
Height = 5415
Left = 120
TabIndex = 0
Top = 120
Width = 7455
_Version = 131072
_ExtentX = 13150
_ExtentY = 9551
_StockProps = 225
BackColor = 16777215
BorderStyle = 1
Contents = "Form05.frx":0000
End
Begin VB.Label Label1
Caption = "Label1"
Height = 375
Left = 960
TabIndex = 1
Top = 5880
Width = 2415
End
End
Attribute VB_Name = "Form05"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Xue Wei,2003/5/17
'SearchByDistance练习;
Option Explicit
Dim rect As New MapObjects2.Rectangle
Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Set rect = Map1.TrackRectangle
Map1.Refresh
End If
End Sub
Private Sub Map1_AfterLayerDraw(ByVal index As Integer, ByVal canceled As Boolean, ByVal hDC As stdole.OLE_HANDLE)
Dim Radius As Double
Dim recset As MapObjects2.Recordset
Dim sym As New MapObjects2.Symbol
Dim iLayer As Integer
Select Case Combo1.Text
Case "州": iLayer = 2
Case "河流": iLayer = 1
Case "城市": iLayer = 0
End Select
If Not rect Is Nothing Then
Radius = rect.Width * 0.5
Set recset = Map1.Layers(iLayer).SearchByDistance(rect.Center, Radius, "")
sym.SymbolType = moFillSymbol
sym.Style = moSolidFill
sym.color = moLightYellow
If Not recset.EOF Then
Map1.DrawShape recset, sym
End If
sym.color = moRed
sym.SymbolType = moFillSymbol
sym.Style = moLightGrayFill
Map1.DrawShape rect, sym
End If
If Not recset.EOF Then
Label1.Caption = "一共找到" & recset.Count & "个对象。"
Else
Label1.Caption = "在地图上画矩形"
End If
End Sub
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("Rivers")
layer.Symbol.color = moRed
Map1.Layers.Add layer
Set layer = New MapLayer
Set layer.GeoDataset = dc.FindGeoDataset("Cities")
layer.Symbol.color = moBlue
Map1.Layers.Add layer
End Sub
Private Sub Form_Load()
DrawLayer
Combo1.AddItem "城市"
Combo1.AddItem "河流"
Combo1.AddItem "州"
Combo1.ListIndex = 0
'Label1.Caption = "在地图上画矩形"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -