Class: QgsMapHitTest¶
Runs a hit test with given map settings.
Based on the hit test it returns which symbols will be visible on the map - this is useful for content based legend.
Methods
Tests whether a given legend key is visible for a specified layer. |
|
Returns the hit test results, which are a map of layer ID to visible symbol legend keys. |
|
Runs the map hit test |
|
Tests whether a symbol is visible for a specified layer. |
- class qgis.core.QgsMapHitTest[source]¶
Bases:
object
- __init__(settings: QgsMapSettings, polygon: QgsGeometry = QgsGeometry(), layerFilterExpression: Dict[str | None, str | None] = {})
Constructor for QgsMapHitTest.
- Parameters:
settings (QgsMapSettings) – Map settings used to evaluate symbols
polygon (
QgsGeometry
= QgsGeometry()) – Polygon geometry to refine the hit testlayerFilterExpression (Dict[Optional[str], Optional[str]] = {}) – Expression string for each layer id to evaluate in order to refine the symbol selection
- __init__(settings: QgsMapSettings, layerFilterExpression: Dict[str | None, str | None])
Constructor version used with only expressions to filter symbols (no extent or polygon intersection)
- Parameters:
settings (QgsMapSettings)
layerFilterExpression (Dict[Optional[str], Optional[str]])
- __init__(settings: QgsLayerTreeFilterSettings)
Constructor based off layer tree filter
settings
.Added in version 3.32.
- Parameters:
settings (QgsLayerTreeFilterSettings)
- __init__(a0: QgsMapHitTest)
- Parameters:
a0 (QgsMapHitTest)
- legendKeyVisible(self, ruleKey: str | None, layer: QgsVectorLayer | None) bool [source]¶
Tests whether a given legend key is visible for a specified layer.
- Parameters:
ruleKey (Optional[str]) – legend rule key
layer (Optional[QgsVectorLayer]) – vector layer
See also
- Return type:
bool
- results(self) Any ¶
Returns the hit test results, which are a map of layer ID to visible symbol legend keys.
Added in version 3.32.
- Return type:
Any
- symbolVisible(self, symbol: QgsSymbol | None, layer: QgsVectorLayer | None) bool [source]¶
Tests whether a symbol is visible for a specified layer.
- Parameters:
symbol (Optional[QgsSymbol]) – symbol to find
layer (Optional[QgsVectorLayer]) – vector layer
See also
- Return type:
bool