📄 form08.frm
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "mo20.ocx"
Begin VB.Form Form08
Caption = "Form"
ClientHeight = 6195
ClientLeft = 60
ClientTop = 345
ClientWidth = 6975
LinkTopic = "Form1"
ScaleHeight = 6195
ScaleWidth = 6975
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 2760
TabIndex = 1
Top = 5520
Width = 1335
End
Begin MapObjects2.Map Map1
Height = 4815
Left = 0
TabIndex = 0
Top = 0
Width = 6975
_Version = 131072
_ExtentX = 12303
_ExtentY = 8493
_StockProps = 225
BackColor = 16777215
BorderStyle = 1
Contents = "Form08.frx":0000
End
Begin VB.Label Label1
Caption = "Label1"
Height = 375
Left = 1080
TabIndex = 2
Top = 4920
Width = 4815
End
End
Attribute VB_Name = "Form08"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Xuewei,2003/6/14
'用Export方法产生prj文件;
Option Explicit
Dim dc As New DataConnection
Private Sub Command1_Click()
Dim PCS As New MapObjects2.ProjCoordSys
Dim Layer1 As MapObjects2.MapLayer
Dim Str1 As String
Set Layer1 = Map1.Layers("states1")
PCS.Type = 54019
With Layer1
Str1 = dc.Database + "\states1.prj"
.CoordinateSystem = PCS
.CoordinateSystem.Export (Str1)
Label1.Caption = DisplayCoords(Layer1)
End With
MsgBox "坐标系文件已经产生"
End Sub
Private Function DisplayCoords(myLayer As MapObjects2.MapLayer) As String
Dim coordSys
Dim PCS As New MapObjects2.ProjCoordSys
Dim GCS As New MapObjects2.GeoCoordSys
Set coordSys = myLayer.CoordinateSystem
If coordSys.IsProjected Then
Set PCS = myLayer.CoordinateSystem
DisplayCoords = "图层为投影坐标系,Type=" & PCS.Type & ",Unit=" & PCS.Unit.name & _
",Projection=" & PCS.Projection.name & ",GeoCoordSys=" & PCS.GeoCoordSys.Type
ElseIf Not coordSys.IsProjected Then
Set GCS = myLayer.CoordinateSystem
DisplayCoords = "图层为地理坐标系,Type=" & GCS.Type & ",Unit=" & GCS.Unit.name & _
",Datum=" & GCS.Datum.name & ",PrimeMeridian=" & GCS.PrimeMeridian.name
End If
End Function
Private Sub Form_Load()
DrawLayer
Me.Caption = "坐标系文件产生"
Command1.Caption = "开始"
End Sub
Private Sub DrawLayer()
Dim Layer As MapLayer
On Error GoTo Err1
dc.Database = App.Path + "\..\" + "Mexico"
Set Layer = New MapLayer
Set Layer.GeoDataset = dc.FindGeoDataset("states")
Label1.Caption = DisplayCoords(Layer)
Map1.Layers.Add Layer
Set Layer = New MapLayer
Set Layer.GeoDataset = dc.FindGeoDataset("states1")
Map1.Layers.Add Layer
Exit Sub
Err1:
If dc.ConnectError = 0 Then
MsgBox "没找到图层", vbInformation, "MO示例"
Else
MsgBox ConnectErrorMsg(dc.ConnectError), vbInformation, "MO示例"
End If
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -