form07a.frm

来自「一个关于基于MO编程的参考资料希望对大家的交流和学习有帮助」· FRM 代码 · 共 109 行

FRM
109
字号
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "mo20.ocx"
Begin VB.Form Form07a 
   Caption         =   "墨西哥地图"
   ClientHeight    =   6360
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8400
   LinkTopic       =   "Form1"
   ScaleHeight     =   6360
   ScaleWidth      =   8400
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command2 
      Caption         =   "放大"
      Height          =   495
      Left            =   4440
      TabIndex        =   2
      Top             =   5760
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "画矩形"
      Height          =   495
      Left            =   2520
      TabIndex        =   1
      Top             =   5760
      Width           =   1335
   End
   Begin MapObjects2.Map Map1 
      Height          =   5655
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   8415
      _Version        =   131072
      _ExtentX        =   14843
      _ExtentY        =   9975
      _StockProps     =   225
      BackColor       =   16777215
      BorderStyle     =   1
      Contents        =   "form07a.frx":0000
   End
End
Attribute VB_Name = "Form07a"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Xuewei,2003/5/19
'在图上画矩形,放大到屏幕。

Option Explicit
Dim Rect As MapObjects2.Rectangle

Private Sub Command1_Click()
  Dim Dist As Double
  Dim Pt As MapObjects2.Point
  
  Set Rect = New MapObjects2.Rectangle
  Set Pt = Map1.ToMapPoint(2000, 2000)
  Dist = 2
  'MsgBox pt.X
  Rect.Right = Pt.X + Dist
  Rect.Left = Pt.X - Dist
  Rect.Top = Pt.Y + Dist
  Rect.Bottom = Pt.Y - Dist
    
  Map1.Refresh
End Sub

Private Sub Command2_Click()
  Map1.Extent = Rect
End Sub

Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As stdole.OLE_HANDLE)
  Dim sym As New Symbol
  If Not Rect Is Nothing Then
    sym.SymbolType = moFillSymbol
    sym.Style = 8
    sym.Size = 2
    sym.Color = moRed
    Map1.DrawShape Rect, sym
  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
  
  Map1.Layers.Add layer
End Sub

Private Sub Form_Load()
  DrawLayer
  
End Sub


⌨️ 快捷键说明

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