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

📄 form07.frm

📁 VB+M0开发GIS代码
💻 FRM
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "Mo20.ocx"
Begin VB.Form Form07 
   Caption         =   "联合查询"
   ClientHeight    =   6270
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7710
   LinkTopic       =   "Form1"
   ScaleHeight     =   6270
   ScaleWidth      =   7710
   StartUpPosition =   2  'CenterScreen
   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        =   "Form07.frx":0000
   End
   Begin VB.Label Label1 
      Caption         =   "Label1"
      Height          =   375
      Left            =   2520
      TabIndex        =   1
      Top             =   5760
      Width           =   2415
   End
End
Attribute VB_Name = "Form07"
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 gSel As MapObjects2.Recordset
Dim recs As MapObjects2.Recordset

    
'添加Map1_AfterLayerDraw过程,以把查找的区域用黄色显示:
Private Sub Map1_AfterLayerDraw(ByVal index As Integer, ByVal canceled As Boolean, ByVal hDC As stdole.OLE_HANDLE)
  Dim sym1 As New MapObjects2.Symbol
  Dim sym2 As New MapObjects2.Symbol
 
  If Not gSel Is Nothing Then
    sym1.color = moYellow
    sym2.SymbolType = moLineSymbol
    sym2.color = moRed
    sym2.Size = 3
    Map1.DrawShape gSel, sym1
    Map1.DrawShape recs, sym2
  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
  Label1.Caption = "在地图上点击河流。"
End Sub

Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  Dim p As MapObjects2.Point
  Set p = Map1.ToMapPoint(X, Y)
  Set recs = Map1.Layers("Rivers").SearchByDistance(p, Map1.ToMapDistance(30), "")
  If recs.EOF Then
    Set gSel = Nothing
    Label1.Caption = "没有找到对象。"
  Else
    
    Set gSel = Map1.Layers("States").SearchShape(recs.Fields("Shape").Value, moEdgeTouchOrAreaIntersect, "")
    Label1.Caption = "一共找到" & gSel.Count & "个对象。"
  End If
  
  Map1.Refresh
End Sub


⌨️ 快捷键说明

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