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

📄 form03a.frm

📁 给出了详细的vb环境下mo基本功能的代码 如图层的加载
💻 FRM
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "mo20.ocx"
Begin VB.Form Form03a 
   Caption         =   "世界地图"
   ClientHeight    =   5415
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7215
   LinkTopic       =   "Form1"
   ScaleHeight     =   5415
   ScaleWidth      =   7215
   StartUpPosition =   2  '屏幕中心
   Begin VB.OptionButton Option2 
      Caption         =   "Option2"
      Height          =   255
      Left            =   4680
      TabIndex        =   4
      Top             =   4920
      Width           =   1815
   End
   Begin VB.OptionButton Option1 
      Caption         =   "Option1"
      Height          =   255
      Left            =   2880
      TabIndex        =   3
      Top             =   4920
      Value           =   -1  'True
      Width           =   1695
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   495
      Left            =   960
      TabIndex        =   2
      Top             =   4800
      Width           =   1335
   End
   Begin MapObjects2.Map Map1 
      Height          =   3975
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   6975
      _Version        =   131072
      _ExtentX        =   12303
      _ExtentY        =   7011
      _StockProps     =   225
      BackColor       =   16777215
      BorderStyle     =   1
      Contents        =   "Form03a.frx":0000
   End
   Begin VB.Label Label1 
      Caption         =   "Label1"
      Height          =   255
      Left            =   840
      TabIndex        =   1
      Top             =   4320
      Width           =   5055
   End
End
Attribute VB_Name = "Form03a"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Xue Wei,2003/6/10
'ToMapDistance和ToMapPoint练习;
'改变ScaleMode后,在世界地图上显示点击处经纬度;

Option Explicit

Private Sub Command1_Click()
  Dim mapGCS As New MapObjects2.GeoCoordSys
  mapGCS.Type = Map1.Layers(0).CoordinateSystem.Type
  MsgBox "Datum = " & mapGCS.Datum.Name & " ,PrimeMeridian = " & mapGCS.PrimeMeridian.Name
End Sub

Private Sub Form_Load()
  Label1.Caption = "点击地图显示经纬度。"
  DrawLayer   '加载世界地图;
  Command1.Caption = "显示坐标信息"
  Option1.Caption = "ToMapDistance"
  Option2.Caption = "ToMapPoint"
  Me.ScaleMode = 6  'mm
End Sub

Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  Dim Str1 As String
  Dim P1 As MapObjects2.Point
  Dim Fx As Single, Fy As Single
        
  '把点击得到的twips转换为新的ScaleMode;
  Fx = Me.ScaleX(X, vbTwips, Me.ScaleMode)
  Fy = Me.ScaleY(Y, vbTwips, Me.ScaleMode)
  
  If Not Option1 Then
    Set P1 = Map1.ToMapPoint(Fx, Fy)
    Str1 = "x=" & Format(P1.X, "0.000") & ",y=" & Format(P1.Y, "0.000")
  Else
    Str1 = "x=" & Format(Map1.ToMapDistance(Fx), "0.000") & ",y=" & Format(Map1.ToMapDistance(Fy), "0.000")
  End If
  Label1.Caption = Str1
End Sub

Sub DrawLayer()
  Dim dc As New DataConnection
  Dim layer As MapLayer
  
  dc.Database = App.Path + "\..\" + "world"
  If Not dc.Connect Then
    MsgBox "在指定的文件夹下没找到图层数据文件!"
    End
  End If
  
  Set layer = New MapLayer
  Set layer.GeoDataset = dc.FindGeoDataset("country")
  layer.Symbol.Color = moRed
  Map1.Layers.Add layer
  
  Set layer = New MapLayer
  Set layer.GeoDataset = dc.FindGeoDataset("latlon")
  layer.Symbol.Color = moDarkGreen
  Map1.Layers.Add layer
End Sub

⌨️ 快捷键说明

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