⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 地理信息系统MO开发的小程序
💻 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 + -