代码名称:有关MAPX中全层显示的代码

作者/收集者:zhaozidong

开发环境:VB + MapX

代码:


全层显示代码

Private Sub combo1_Click()
    Dim rect As MapXLib.Rectangle
    
    If Combo1.Text <> "All Layers" Then
        Set rect = Formmain.Map1.Layers(Combo1.Text).Bounds
        xmaxvalue = str(rect.XMAX)
        ymaxvalue = str(rect.YMAX)
        xminvalue = str(rect.XMIN)
        yminvalue = str(rect.YMIN)
    End If
    Set rect = Nothing
    
End Sub

Private Sub Command1_Click()
    
    Dim lyr As MapXLib.Layer
        
    On Error GoTo error1
    
    Formmain.Map1.NumericCoordSys = Formmain.Map1.DisplayCoordSys
    
    If Combo1.Text = "All Layers" Then
        Set Formmain.Map1.Bounds = Formmain.Map1.Layers.Bounds
    Else
       Set lyr = Formmain.Map1.Layers(Combo1.Text)
       Set Formmain.Map1.Bounds = lyr.Bounds
    End If
    
    Unload Me

error1:
    Select Case Err.Number
       Case 1074
         MsgBox "在图层中没有发现对象", , "警告"
         Unload Me
    End Select
    
    
End Sub

Private Sub Command2_Click()
    Unload Me
End Sub

Private Sub Form_Load()
    Dim lyr As MapXLib.Layer
    
    For Each lyr In Formmain.Map1.Layers
       Combo1.AddItem lyr.Name
    Next
     Combo1.AddItem "All Layers"
         
     Combo1.ListIndex = 0
    
End Sub

控件解释:
combo1???tab表的列表
command2??取消
command1??全层显示确定
在窗体上还有8个label控件,分别为:
xmaxvalue
ymaxvalue
xminvalue
yminvalue
xmax
ymax
xmin
ymin