| | |
| | | <custom-order enabled="0"/> |
| | | </layer-tree-group> |
| | | </LayoutItem> |
| | | <LayoutItem size="278.717,173.275,mm" position="9.47563,16.5367,mm" id="地图" outlineWidthM="4,px" referencePoint="0" type="65639" frame="true" followPreset="false" isTemporal="0" visibility="1" positionLock="true" blendMode="0" opacity="1" labelMargin="0,mm" templateUuid="{4e649c5d-cabe-431f-a385-d69809d87ebf}" mapFlags="0" itemRotation="0" frameJoinStyle="round" mapRotation="0" groupUuid="" keepLayerSet="false" excludeFromExports="0" drawCanvasItems="false" positionOnPage="9.47563,16.5367,mm" uuid="{4e649c5d-cabe-431f-a385-d69809d87ebf}" followPresetName="" background="true" zValue="2"> |
| | | <LayoutItem size="278.717,173.275,mm" position="9.47563,16.5367,mm" id="阀室,管道中心线,矢量注记,矢量图" outlineWidthM="4,px" referencePoint="0" type="65639" frame="true" followPreset="false" isTemporal="0" visibility="1" positionLock="true" blendMode="0" opacity="1" labelMargin="0,mm" templateUuid="{4e649c5d-cabe-431f-a385-d69809d87ebf}" mapFlags="0" itemRotation="0" frameJoinStyle="round" mapRotation="0" groupUuid="" keepLayerSet="false" excludeFromExports="0" drawCanvasItems="false" positionOnPage="9.47563,16.5367,mm" uuid="{4e649c5d-cabe-431f-a385-d69809d87ebf}" followPresetName="" background="true" zValue="2"> |
| | | <FrameColor red="0" green="0" blue="0" alpha="255"/> |
| | | <BackgroundColor red="255" green="255" blue="255" alpha="255"/> |
| | | <LayoutObject> |
| | |
| | | #!/usr/bin/env |
| | | # -*- coding: utf-8 -*- |
| | | import os |
| | | import math |
| | | from qgis.core import * |
| | |
| | | from qgis.PyQt.QtXml import * |
| | | |
| | | |
| | | # 设置图层可用性 |
| | | def setLayersValid(project, showLayers): |
| | | for layer in project.mapLayers().values(): |
| | | flag = layer.name() in showLayers |
| | |
| | | layer.setValid(flag) |
| | | |
| | | |
| | | # 设置图层可见性 |
| | | def setItemVisibility(root, showLayers): |
| | | print('Group: ' + root.name()) |
| | | print(root.name() + ': Group') |
| | | for node in root.children(): |
| | | # QgsLayerTreeLayer |
| | | if isinstance(node, QgsLayerTreeGroup): |
| | |
| | | else: |
| | | name = node.layer().name() |
| | | flag = name in showLayers |
| | | print(str(flag) + ", " + name) |
| | | print(name + ": " + str(flag)) |
| | | # if not flag: |
| | | # root.removeLayer(node.layer()) |
| | | # node.layer().setValid(False) |
| | |
| | | print('1:' + str(math.ceil(map.scale()))) |
| | | |
| | | # "阀室", "站场", "管道中心线", "矢量注记", "矢量图", "高德影像注记", "高德影像", "影像注记", "影像图" |
| | | showLayers = ["阀室", "管道中心线", "矢量注记", "矢量图"] |
| | | # showLayers = ["阀室", "管道中心线", "矢量注记", "矢量图"] |
| | | showLayers = map.id().split(',') |
| | | root = project.layerTreeRoot() |
| | | # setLayersValid(project, showLayers) |
| | | setItemVisibility(root, showLayers) |