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

📄 form3.frm

📁 给出了详细的vb环境下mo基本功能的代码 如图层的加载
💻 FRM
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "mo20.ocx"
Begin VB.Form Form3 
   Caption         =   "Form1"
   ClientHeight    =   5550
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6255
   LinkTopic       =   "Form1"
   ScaleHeight     =   5550
   ScaleWidth      =   6255
   StartUpPosition =   3  '窗口缺省
   Begin VB.Timer Timer1 
      Left            =   1320
      Top             =   5160
   End
   Begin MapObjects2.Map Map1 
      Height          =   4695
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   6015
      _Version        =   131072
      _ExtentX        =   10610
      _ExtentY        =   8281
      _StockProps     =   225
      BackColor       =   16777215
      BorderStyle     =   1
      Contents        =   "Form3.frx":0000
   End
   Begin VB.Label Label1 
      Caption         =   "点击图形开始"
      Height          =   255
      Left            =   2400
      TabIndex        =   1
      Top             =   5040
      Width           =   1455
   End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim ploygon As MapObjects2.Polygon
Dim Num As Integer


Private Sub Form_Load()
  Dim Layer As MapLayer
  Dim dc As New DataConnection
  dc.Database = App.Path
  If Not dc.Connect Then
    MsgBox "在指定的文件夹下没找到图层数据文件,退出GIS!"
    Unload Me
    Exit Sub
  End If
  Set Layer = New MapLayer
  Set Layer.GeoDataset = dc.FindGeoDataset("图层 1_s_s")
  Layer.Name = "图层 1"
  Layer.Symbol.Color = moPaleYellow
  Layer.Symbol.Size = 2
  Layer.Symbol.OutlineColor = moKhaki
  Map1.Layers.Add Layer
  
  Map1.Refresh
  
  Map1.TrackingLayer.SymbolCount = 1
  With Map1.TrackingLayer.Symbol(0)
        .SymbolType = moFillSymbol
        .Color = moBlue
        .Style = 0
        .Size = 1
        .OutlineColor = moRed
  End With
  Num = 0

End Sub

Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim recs1 As MapObjects2.Recordset
    Dim p1 As MapObjects2.Point
    Set Layer1 = Map1.Layers(0)
    Set p1 = Map1.ToMapPoint(X, Y)
    Set recs1 = Layer1.SearchByDistance(p1, theTol, "")
    Timer1.Interval = 0
    If Not recs1.EOF And Map1.Layers(0).Visible = True Then
        Set ploygon = recs1("Shape").Value
        Timer1.Interval = 500
    End If

End Sub

Private Sub Timer1_Timer()
    Dim poly As New MapObjects2.Polygon
    Dim i
    If Num >= ploygon.Parts(0).Count Then
        Timer1.Interval = 0
        Num = 0
        Exit Sub
    End If
    Dim pt As New MapObjects2.Point
    Dim pts As New MapObjects2.Points
    
    If Map1.TrackingLayer.EventCount > 0 Then
        Map1.TrackingLayer.ClearEvents
    End If

    For i = 0 To Num
        pt.X = ploygon.Parts(0).Item(i).X
        pt.Y = ploygon.Parts(0).Item(i).Y
        pts.Add pt
    Next i
    poly.Parts.Add pts
    Map1.TrackingLayer.AddEvent poly, 0
    Num = Num + 1

End Sub

⌨️ 快捷键说明

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