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

📄 view.frm

📁 mo的GPS例子程序
💻 FRM
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "Mo20.ocx"
Object = "{5885784C-33C4-11D3-AE7F-00C04F6BDDD7}#1.0#0"; "MO2LEG~2.OCX"
Object = "{D72D0F0E-3D40-11D3-BE6A-0080C718BDC2}#1.0#0"; "ScaleBar.ocx"
Begin VB.Form frmView 
   Caption         =   "View"
   ClientHeight    =   6315
   ClientLeft      =   255
   ClientTop       =   540
   ClientWidth     =   6885
   LinkTopic       =   "Form1"
   ScaleHeight     =   6315
   ScaleWidth      =   6885
   Begin MapObjects2.Map mapView 
      Height          =   4320
      Left            =   2400
      TabIndex        =   0
      Top             =   840
      Width           =   4320
      _Version        =   131072
      _ExtentX        =   7620
      _ExtentY        =   7620
      _StockProps     =   225
      BackColor       =   16777215
      BorderStyle     =   1
      ScrollBars      =   0   'False
      Contents        =   "view.frx":0000
   End
   Begin VB.PictureBox picArrow 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      BorderStyle     =   0  'None
      ForeColor       =   &H80000008&
      Height          =   980
      Left            =   120
      Picture         =   "view.frx":001A
      ScaleHeight     =   975
      ScaleWidth      =   975
      TabIndex        =   9
      Top             =   5280
      Width           =   980
   End
   Begin VB.OptionButton optMapUnits 
      Alignment       =   1  'Right Justify
      Caption         =   "Meters"
      Height          =   255
      Index           =   2
      Left            =   120
      TabIndex        =   6
      Top             =   240
      Value           =   -1  'True
      Width           =   855
   End
   Begin VB.OptionButton optMapUnits 
      Alignment       =   1  'Right Justify
      Caption         =   "Miles"
      Height          =   255
      Index           =   0
      Left            =   120
      TabIndex        =   5
      Top             =   480
      Width           =   855
   End
   Begin MO2legend.legend legMapView 
      Height          =   4320
      Left            =   120
      TabIndex        =   4
      Top             =   840
      Width           =   2160
      _ExtentX        =   3810
      _ExtentY        =   7620
      BackColor       =   -2147483644
      ForeColor       =   -2147483630
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin VB.CommandButton cmdCreateMapComp 
      Caption         =   "Create Map Composition"
      Height          =   375
      Left            =   1200
      TabIndex        =   3
      Top             =   240
      Width           =   1935
   End
   Begin VB.TextBox txtTitle 
      Height          =   285
      Left            =   4560
      TabIndex        =   1
      Text            =   "My Map"
      Top             =   360
      Width           =   2175
   End
   Begin ScaleBar.sbScaleBar sbMapView 
      Height          =   720
      Left            =   2400
      TabIndex        =   7
      Top             =   5280
      Width           =   4320
      _ExtentX        =   7620
      _ExtentY        =   1270
      BackColor       =   16777215
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BarWidth        =   3
   End
   Begin VB.Label lblScalebarUnits 
      Caption         =   "Scalebar Units"
      Height          =   255
      Left            =   120
      TabIndex        =   8
      Top             =   0
      Width           =   1215
   End
   Begin VB.Label lblTitle 
      Caption         =   "Map Title:"
      Height          =   255
      Left            =   4560
      TabIndex        =   2
      Top             =   120
      Width           =   2175
   End
End
Attribute VB_Name = "frmView"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public map_aspect, legend_aspect As Single
'

Private Sub cmdCreateMapComp_Click()

'Deactive all layers
Dim i As Integer
For i = 0 To mapView.Layers.Count - 1
  legMapView.Active(i) = False
Next

'Read frame aspect ratios
Call ResetAspectRatios

'Open the Layout window
frmLayout.Show vbModeless

End Sub


Private Sub Form_Load()

'Load data
'Dim ilyr As New MapObjects2.ImageLayer
'ilyr.File = "d:\esri\esridata\usa\image\usa-shd.tif"
'mapView.Layers.Add ilyr
Dim dc As New MapObjects2.DataConnection
Dim mlyr As New MapObjects2.MapLayer
dc.Database = App.Path & "\data"
dc.Connect
Set mlyr.GeoDataset = dc.FindGeoDataset("states2")
mlyr.Symbol.Color = moLightGray
mapView.Layers.Add mlyr
Set mlyr = Nothing
Set mlyr.GeoDataset = dc.FindGeoDataset("ushigh2")
mlyr.Symbol.Color = moRed - &H20 'dark red
mapView.Layers.Add mlyr
Set mlyr = Nothing
Set mlyr.GeoDataset = dc.FindGeoDataset("capitals2")
mlyr.Symbol.Style = moTriangleMarker
mlyr.Symbol.Size = 5
mlyr.Symbol.Color = moGreen - &H2000  'dark green
mapView.Layers.Add mlyr

'Bind legend to map, and set legend properties
With legMapView
  .BackColor = &HE0E0E0
  .setMapSource mapView
  .LoadLegend True
  .ShowAllLegend
  .Active(0) = True
End With

'Set Scalebar properties
Dim fntScalebar As New stdole.StdFont
fntScalebar.Name = "Arial Narrow"
fntScalebar.Size = 10
With sbMapView
  .AdjustForLatitude = True
  .BackColor = moWhite
  .BarColor1 = &H808080  'medium gray
  .BarColor2 = &HFFC0C0  'light blue
  .BarWidth = 4
  .BorderStyle = vbBSSolid
  Set .Font = fntScalebar
  .MapUnits = scalebar.sbMapUnits.muDecimalDegrees
  .MinTicSpace = 0.6
  .ScaleBarUnits = scalebar.sbScaleBarUnits.suMeters
End With
  
End Sub

Private Sub Form_Resize()

On Error Resume Next

If Not Me.Width < 2600 Then

  'Adjust Legend
  legMapView.Height = Me.Height - 2420
  
  'Adjust Map
  mapView.Width = Me.Width - 2680
  mapView.Height = Me.Height - 2180
  
  'Adjust Scalebar elements
  sbMapView.Width = mapView.Width
  sbMapView.Top = mapView.Top + mapView.Height + 120
  
  'Adjust North Arrow
  picArrow.Top = legMapView.Top + legMapView.Height + 120
  
End If

Call ResetAspectRatios

End Sub

Private Sub legMapView_AfterSetLayerVisible(Index As Integer, isVisible As Boolean)

mapView.Refresh

End Sub

Private Sub mapView_AfterTrackingLayerDraw(ByVal hDC As stdole.OLE_HANDLE)

'User can create a map composition only if there
'is at least one layer in the map control.
cmdCreateMapComp.Enabled = (mapView.Layers.Count > 0)

'Refresh the scale bar to the new extent
Call RefreshScale(sbMapView, mapView)

End Sub

Public Sub RefreshScale(sb As scalebar.sbScaleBar, MOMap As MapObjects2.Map)

  Dim MapExt As scalebar.sbExtent
  Dim Pageext As scalebar.sbExtent
  
  'Reset the scalebar to fit the measurements
  'on the map control.
  
  On Error Resume Next
  Set MapExt = sb.MapExtent
  Set Pageext = sb.PageExtent
  
  MapExt.MinX = MOMap.Extent.Left
  MapExt.MinY = MOMap.Extent.Bottom
  MapExt.MaxX = MOMap.Extent.Right
  MapExt.MaxY = MOMap.Extent.Top
  
  Pageext.MinX = MOMap.Left / Screen.TwipsPerPixelX
  Pageext.MinY = MOMap.Top / Screen.TwipsPerPixelY
  Pageext.MaxX = (MOMap.Left + MOMap.Width) / Screen.TwipsPerPixelX
  Pageext.MaxY = (MOMap.Top + MOMap.Height) / Screen.TwipsPerPixelY
  
  sb.Refresh

End Sub

Private Sub mapView_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

'Basic pan/zoom tool
If Shift = 0 Then
  If Button = 1 Then
   Set mapView.Extent = mapView.TrackRectangle
    Else
     mapView.Pan
  End If
 Else
  If Button = 1 Then
    Dim rect As MapObjects2.Rectangle
     Set rect = mapView.Extent
     rect.ScaleRectangle (1.2)
     Set mapView.Extent = rect
   Else
     Set mapView.Extent = mapView.FullExtent
  End If
End If

End Sub

Private Sub optMapUnits_Click(Index As Integer)

'Index 0 is MILES; Index 2 is METERS
sbMapView.ScaleBarUnits = Index
sbMapView.Refresh

End Sub

Public Sub ResetAspectRatios()

'Populate variables to hold frame aspect ratios

'...leave vertical space of 120 twips between map and scalebar
map_aspect = mapView.Width / (mapView.Height + 120 + sbMapView.Height)
'...chop off left 280 twips of legend to eliminate check boxes.
legend_aspect = (legMapView.Width - 280) / legMapView.Height

End Sub

⌨️ 快捷键说明

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