アクティブ データ フレームの指定した名称のレイヤー表示を切り替え

      2017/12/09

Public Sub ChangeVisibleLayer(Optional LayerName As String = "")
 
    If LayerName = "" Then
        LayerName = InputBox("表示を切り替えるレイヤを入力してください。", "レイヤ表示切り替え")
        If LayerName = "" Then Exit Sub
    End If
     
    Dim pMxDocument As IMxDocument
    Set pMxDocument = ThisDocument
     
    If pMxDocument.FocusMap.LayerCount = 0 Then Exit Sub
     
    Dim pEnumLayer As IEnumLayer
    Set pEnumLayer = pMxDocument.FocusMap.Layers(Nothing, False)
    pEnumLayer.Reset
     
    Dim pLayer As ILayer
    Set pLayer = pEnumLayer.Next
     
    Do Until pLayer Is Nothing
     
        If pLayer.Name = LayerName Then
                 pLayer.Visible = Not pLayer.Visible
        End If
        Set pLayer = pEnumLayer.Next
    Loop
     
    '再描画
    pMxDocument.UpdateContents
    pMxDocument.ActiveView.Refresh
 
End Sub

 - プログラミング, ArcGIS , ,