Class: QgsMapHitTest¶
- class qgis.core.QgsMapHitTest¶
Bases:
sip.wrapper
Class that 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.
QgsMapHitTest(settings:
QgsMapSettings
, polygon:QgsGeometry
= QgsGeometry(), layerFilterExpression: Dict[Optional[str], Optional[str]] = {})- Parameters:
settings – Map settings used to evaluate symbols
polygon – Polygon geometry to refine the hit test
layerFilterExpression – Expression string for each layer id to evaluate in order to refine the symbol selection
QgsMapHitTest(settings:
QgsMapSettings
, layerFilterExpression: Dict[Optional[str], Optional[str]]) Constructor version used with only expressions to filter symbols (no extent or polygon intersection)QgsMapHitTest(settings:
QgsLayerTreeFilterSettings
) Constructor based off layer tree filtersettings
.Added in version 3.32.
QgsMapHitTest(a0:
QgsMapHitTest
)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.
- legendKeyVisible(self, ruleKey: str | None, layer: QgsVectorLayer | None) bool ¶
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
- run(self)¶
Runs the map hit test
- symbolVisible(self, symbol: QgsSymbol | None, layer: QgsVectorLayer | None) bool ¶
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