如何用代码设置图层在特定比例尺下显示

本文介绍了一个用于ArcGIS的自定义命令实现,该命令能够根据子类型设置地图图层的最大和最小比例尺阈值,或者移除这些阈值。通过三种不同的子类型操作,可以灵活地控制地图上图层的可见性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Option Explicit

Implements ICommand
Implements ICommandSubType

Private m_pHookHelper As IHookHelper
Private m_pMapControl As IMapControl3
Private m_lSubType As Long

Private Sub Class_Initialize()
  
  Set m_pHookHelper = New HookHelper
  
End Sub

Private Sub Class_Terminate()
  
  Set m_pHookHelper = Nothing
  
End Sub

Private Property Get ICommand_Enabled() As Boolean
  
  Dim bEnabled As Boolean
  bEnabled = True

  Dim pLayer As ILayer
  Set pLayer = m_pMapControl.CustomProperty

  If (m_lSubType = 3) Then
    If (pLayer.MaximumScale = 0) And (pLayer.MinimumScale = 0) Then bEnabled = False
  End If
  
  ICommand_Enabled = bEnabled
  
End Property

Private Property Get ICommand_Checked() As Boolean
  
  ICommand_Checked = False
  
End Property

Private Property Get ICommand_Name() As String
  
  ICommand_Name = "ScaleThresholds"
  
End Property

Private Property Get ICommand_Caption() As String
  
  If (m_lSubType = 1) Then
    ICommand_Caption = "Set Maximum Scale"
  ElseIf (m_lSubType = 2) Then
    ICommand_Caption = "Set Minimum Scale"
  Else
    ICommand_Caption = "Remove Scale Thresholds"
  End If

End Property

Private Property Get ICommand_Tooltip() As String
  
  'Not implemented
  
End Property

Private Property Get ICommand_Message() As String
  
  'Not implemented
  
End Property

Private Property Get ICommand_HelpFile() As String
  
  'Not implemented
  
End Property

Private Property Get ICommand_HelpContextID() As Long
  
  'Not implemented
  
End Property

Private Property Get ICommand_Bitmap() As esriSystem.OLE_HANDLE
  
  'Not implemented

End Property

Private Property Get ICommand_Category() As String
  
  'Not implemented
  
End Property

Private Sub ICommand_OnCreate(ByVal hook As Object)

  Set m_pHookHelper.hook = hook
  Set m_pMapControl = m_pHookHelper.hook
  
End Sub

Private Sub ICommand_OnClick()
  
  Dim pLayer As ILayer
  Set pLayer = m_pMapControl.CustomProperty
  If (m_lSubType = 1) Then pLayer.MaximumScale = m_pMapControl.MapScale
  If (m_lSubType = 2) Then pLayer.MinimumScale = m_pMapControl.MapScale
  If (m_lSubType = 3) Then
    pLayer.MaximumScale = 0
    pLayer.MinimumScale = 0
  End If
  m_pMapControl.Refresh esriViewDrawPhase.esriViewGeography

End Sub

Private Sub ICommandSubType_SetSubType(ByVal SubType As Long)

  m_lSubType = SubType

End Sub

Private Function ICommandSubType_GetCount() As Long

  ICommandSubType_GetCount = 3

End Function

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值