?? form1.frm
字號:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "mo20.ocx"
Begin VB.Form Form1
Caption = "SearchExpression方法示例"
ClientHeight = 3720
ClientLeft = 1095
ClientTop = 1515
ClientWidth = 5055
LinkTopic = "Form1"
PaletteMode = 1 'UseZOrder
ScaleHeight = 3720
ScaleWidth = 5055
Begin VB.TextBox Text1
Height = 270
Left = 1080
TabIndex = 2
Top = 3360
Width = 3855
End
Begin MapObjects2.Map Map1
Height = 3135
Left = 120
TabIndex = 0
Top = 120
Width = 4815
_Version = 131072
_ExtentX = 8493
_ExtentY = 5530
_StockProps = 225
BackColor = 16777215
BorderStyle = 1
Contents = "form1.frx":0000
End
Begin VB.Label Label1
Caption = "查詢條件:"
Height = 255
Left = 120
TabIndex = 1
Top = 3360
Width = 975
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'符合條件的地理對象集合
Dim SelectedFeatures As MapObjects2.Recordset
Private Sub Form_Load()
Text1.Text = ""
Set SelectedFeatures = Nothing
'調入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
Private Sub Map1_AfterLayerDraw(ByVal index As Integer, ByVal canceled As Boolean, ByVal hDC As stdole.OLE_HANDLE)
'將選出的地理對象在AfterLayerDraw事件中以其他顏色重畫以高亮顯示
'判斷是否有符合條件的地理對象
If Not SelectedFeatures Is Nothing Then
'建立Symbol對象以決定地理對象的顯示方式
Dim NewSym As New MapObjects2.Symbol
NewSym.Color = moBlue
'重繪符合條件的地理對象
Map1.DrawShape SelectedFeatures, NewSym
End If
End Sub
Private Sub Text1_Change()
If Text1.Text = "" Then
'查詢條件為空
Set SelectedFeatures = Nothing
Else
'獲取Country圖層
Dim ly As MapObjects2.MapLayer
Set ly = Map1.Layers("country")
'使用SearchExpression方法獲取符合TextBox中查詢語句的地理對象
Set SelectedFeatures = ly.SearchExpression(Text1.Text)
Map1.Refresh
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -