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

📄 form04.frm

📁 VB+M0开发GIS代码
💻 FRM
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "Mo20.ocx"
Begin VB.Form Form04 
   Caption         =   "查找对象周围的特征"
   ClientHeight    =   6450
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7710
   LinkTopic       =   "Form1"
   ScaleHeight     =   6450
   ScaleWidth      =   7710
   StartUpPosition =   2  'CenterScreen
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   4800
      TabIndex        =   2
      Text            =   "Text1"
      Top             =   5760
      Width           =   1095
   End
   Begin MapObjects2.Map Map1 
      Height          =   5415
      Left            =   120
      TabIndex        =   0
      Top             =   240
      Width           =   7455
      _Version        =   131072
      _ExtentX        =   13150
      _ExtentY        =   9551
      _StockProps     =   225
      BackColor       =   16777215
      BorderStyle     =   1
      Contents        =   "Form04.frx":0000
   End
   Begin VB.Label Label2 
      Caption         =   "误差"
      Height          =   255
      Left            =   4080
      TabIndex        =   3
      Top             =   5880
      Width           =   735
   End
   Begin VB.Label Label1 
      Caption         =   "Label1"
      Height          =   375
      Left            =   1320
      TabIndex        =   1
      Top             =   5880
      Width           =   2415
   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/17
'SearchByDistance简单练习;

Option Explicit

Dim recset As MapObjects2.Recordset
Dim Radius As Double
Dim Pp As MapObjects2.Point
Dim sym As New MapObjects2.Symbol


Private Sub Map1_AfterLayerDraw(ByVal index As Integer, ByVal canceled As Boolean, ByVal hDC As stdole.OLE_HANDLE)
  If Not Pp Is Nothing Then
    If Not recset.EOF Then
      '显示查找图形对象;
      Map1.DrawShape recset, sym
      '显示查找个数;
      Label1.Caption = "一共找到" & recset.Count & "个对象。"
    Else
      Label1.Caption = "没有找到对象。"
    End If
  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 = moYellow
  Map1.Layers.Add layer
  
  Set layer = New MapLayer
  Set layer.GeoDataset = dc.FindGeoDataset("Rivers")
  layer.Symbol.color = moOrange
  Map1.Layers.Add layer
  
  Set layer = New MapLayer
  Set layer.GeoDataset = dc.FindGeoDataset("Cities")
  layer.Symbol.color = moLimeGreen
  Map1.Layers.Add layer
End Sub

Private Sub Form_Load()
  '初始设置;
  DrawLayer   '添加States、Rivers和Cities等3个图层;
  Text1.Text = 1
  Label1.Caption = "在地图上点击"
  
  '设置查找后的显示模式;
  sym.Style = 2
  sym.color = moBrown
  sym.Size = 8
End Sub


Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  '将点击转换为点对象;
  Set Pp = Map1.ToMapPoint(X, Y)
  '距离查找;
  Set recset = Map1.Layers(0).SearchByDistance(Pp, Text1.Text, "")
  '调用Map1_AfterLayerDraw显示查找结果;
  Map1.Refresh
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -