Class: QgsMapCanvasUtils¶
- class qgis.gui.QgsMapCanvasUtils¶
Bases:
sip.wrapper
Utility functions for working with
QgsMapCanvas
widgets.New in version 3.14:
Methods
Constructs a filter to use for selecting features from the given
layer
, in order to apply filters which prevent some features from being displayed (e.g.Flashes features from the specified
layer
which match the givenfilter
expression string with a mapcanvas
.Zooms a map
canvas
to features from the specifiedlayer
which match the givenfilter
expression string.- filterForLayer(canvas: QgsMapCanvas, layer: QgsVectorLayer) str ¶
Constructs a filter to use for selecting features from the given
layer
, in order to apply filters which prevent some features from being displayed (e.g. as a result of temporal range of the canvas and the layer’s temporal settings).Will return an empty string if no filtering is required, or “
False
” if ALL features are filtered out by the canvas.New in version 3.26.
- Parameters:
canvas (QgsMapCanvas) –
layer (QgsVectorLayer) –
- Return type:
str
- flashMatchingFeatures(canvas: QgsMapCanvas, layer: QgsVectorLayer, filter: str) int ¶
Flashes features from the specified
layer
which match the givenfilter
expression string with a mapcanvas
.The total count of matching features will be returned.
- Parameters:
canvas (QgsMapCanvas) –
layer (QgsVectorLayer) –
filter (str) –
- Return type:
int
- zoomToMatchingFeatures(canvas: QgsMapCanvas, layer: QgsVectorLayer, filter: str) int ¶
Zooms a map
canvas
to features from the specifiedlayer
which match the givenfilter
expression string.The total count of matching features will be returned.
- Parameters:
canvas (QgsMapCanvas) –
layer (QgsVectorLayer) –
filter (str) –
- Return type:
int