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

📄 form02.frm

📁 VB+MO的GIS开发代码
💻 FRM
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "Mo20.ocx"
Begin VB.Form Form02 
   Caption         =   "多样化渲染"
   ClientHeight    =   5595
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6765
   LinkTopic       =   "Form1"
   ScaleHeight     =   5595
   ScaleWidth      =   6765
   StartUpPosition =   2  'CenterScreen
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   1560
      TabIndex        =   2
      Text            =   "Text1"
      Top             =   4920
      Width           =   855
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   495
      Left            =   3600
      TabIndex        =   1
      Top             =   4920
      Width           =   1215
   End
   Begin MapObjects2.Map Map1 
      Height          =   4575
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   6735
      _Version        =   131072
      _ExtentX        =   11880
      _ExtentY        =   8070
      _StockProps     =   225
      BackColor       =   16777215
      BorderStyle     =   1
      Contents        =   "Form02.frx":0000
   End
End
Attribute VB_Name = "Form02"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Xue Wei,2003/6/6
'使用SymbolField属性;

Option Explicit

Dim moRecset As MapObjects2.Recordset

Private 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 = moOrange
  layer.Symbol.Size = 1
  layer.Symbol.Style = 2
  layer.Symbol.OutlineColor = moBrown
  
  Map1.Layers.Add layer
  
  Set layer = New MapLayer
  Set layer.GeoDataset = dc.FindGeoDataset("Rivers")
  layer.Symbol.Color = moDarkGreen
  layer.Symbol.Size = 2
  Map1.Layers.Add layer
  
  Set layer = New MapLayer
  Set layer.GeoDataset = dc.FindGeoDataset("Cities")
  layer.Symbol.Color = moRed
  layer.Symbol.Size = 3
  Map1.Layers.Add layer
  Map1.Refresh
End Sub

Private Sub Command1_Click()
  Dim oLayer As New MapObjects2.LabelRenderer
  Dim oFnt0 As New StdFont
  Dim oFnt1 As New StdFont
  Dim oFnt2 As New StdFont

  If Int(Text1.Text) < 4 Then
    MsgBox "输入数字必须 > 3 !"
    Exit Sub
  End If
  
  With oFnt0
    .Name = "Arial"
    .Size = 9
    .Italic = True
  End With

  With oFnt1
    .Name = "Courier New"
    .Size = 11
  End With
  
  With oFnt2

    .Name = "Arial"
    .Bold = True
    .Size = 14
  End With

  With oLayer
    .SymbolField = "CITIES_"
    .Field = "NAME"
    .SymbolCount = Text1.Text
    
    Set .Symbol(3).Font = oFnt0
    .Symbol(3).Color = moRed
    Set .Symbol(1).Font = oFnt1
    .Symbol(1).Color = moBlue
    Set .Symbol(2).Font = oFnt2
    .Symbol(2).Color = moDarkGreen
  End With
  Map1.Layers(0).Renderer = oLayer
  Map1.Refresh
 
End Sub

Private Sub Form_Load()
  DrawLayer
  Text1.Text = 4
End Sub

Private Sub Map1_DblClick()
  Map1.Extent = Map1.FullExtent
End Sub

Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  Dim Rect As MapObjects2.Rectangle
  If Button = 1 Then
    Set Rect = Map1.TrackRectangle
    Set Map1.Extent = Rect
  Else
    Map1.Pan
  End If
End Sub


⌨️ 快捷键说明

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