Class: QgsLayoutItemMapItem¶
An item which is drawn inside a QgsLayoutItemMap
, e.g., a
grid or map overview.
Class Hierarchy¶
Base classes¶
A base class for objects which belong to a layout. |
|
Abstract interface for generating an expression context. |
Subclasses¶
An individual grid which is drawn above the map content in a |
|
An individual overview which is drawn above the map content in a |
Methods
Accepts the specified style entity visitor, causing it to visit all style entities associated with the map item. |
|
Draws the item on to a destination painter. |
|
Returns whether the item will be drawn. |
|
Called after all pending items have been restored from XML. |
|
Returns the unique id for the map item. |
|
Returns the layout item map for the item. |
|
Returns the internal map layer used by this item, if available. |
|
Returns the friendly display name for the item. |
|
Sets the map item state from a DOM document, where element is the DOM node corresponding to a 'LayoutMapGrid' tag. |
|
Controls whether the item will be drawn. |
|
Sets the corresponding layout map for the item. |
|
Sets the friendly display name for the item. |
|
Sets the item's stacking layer, which specifies where the in the map's stack the item should be rendered. |
|
Sets the item's stacking position, which specifies where the in the map's stack the item should be rendered. |
|
Returns the item's stacking layer, which specifies where the in the map's stack the item should be rendered. |
|
Returns the item's stacking position, which specifies where the in the map's stack the item should be rendered. |
|
Returns |
|
Stores map item state in a DOM element, where element is the DOM element corresponding to a 'LayoutMap' tag. |
Attributes
- class qgis.core.QgsLayoutItemMapItem[source]¶
Bases:
QgsLayoutObject
- __init__(name: str | None, map: QgsLayoutItemMap | None)
Constructor for QgsLayoutItemMapItem, attached to the specified
map
.The
name
argument gives a friendly display name for the item.- Parameters:
name (Optional[str])
map (Optional[QgsLayoutItemMap])
- StackAboveMapLabels = 4¶
- StackAboveMapLayer = 2¶
- StackBelowMap = 0¶
- StackBelowMapLabels = 3¶
- StackBelowMapLayer = 1¶
- class StackingPosition¶
Bases:
int
- accept(self, visitor: QgsStyleEntityVisitorInterface | None) bool [source]¶
Accepts the specified style entity
visitor
, causing it to visit all style entities associated with the map item.Returns
True
if the visitor should continue visiting other objects, orFalse
if visiting should be canceled.Added in version 3.10.
- Parameters:
visitor (Optional[QgsStyleEntityVisitorInterface])
- Return type:
bool
- draw(self, painter: QPainter | None)[source]¶
Draws the item on to a destination
painter
.- Parameters:
painter (Optional[QPainter])
- finalizeRestoreFromXml(self)[source]¶
Called after all pending items have been restored from XML. Map items can use this method to run steps which must take place after all items have been restored to the layout, such as connecting to signals emitted by other items, which may not have existed in the layout at the time
readXml()
was called. E.g. an overview can use this to connect to its linked map item after restoration from XML.See also
- map(self) QgsLayoutItemMap | None [source]¶
Returns the layout item map for the item.
See also
- Return type:
Optional[QgsLayoutItemMap]
- mapLayer(self) QgsMapLayer | None [source]¶
Returns the internal map layer used by this item, if available.
Added in version 3.10.1.
- Return type:
Optional[QgsMapLayer]
- readXml(self, element: QDomElement, doc: QDomDocument, context: QgsReadWriteContext) bool [source]¶
Sets the map item state from a DOM document, where
element
is the DOM node corresponding to a ‘LayoutMapGrid’ tag.See also
- Parameters:
element (QDomElement)
doc (QDomDocument)
context (QgsReadWriteContext)
- Return type:
bool
- setEnabled(self, enabled: bool)[source]¶
Controls whether the item will be drawn. Set
enabled
toTrue
to enable drawing of the item.See also
- Parameters:
enabled (bool)
- setMap(self, map: QgsLayoutItemMap | None)[source]¶
Sets the corresponding layout
map
for the item.See also
- Parameters:
map (Optional[QgsLayoutItemMap])
- setName(self, name: str | None)[source]¶
Sets the friendly display
name
for the item.See also
- Parameters:
name (Optional[str])
- setStackingLayer(self, layer: QgsMapLayer | None)[source]¶
Sets the item’s stacking
layer
, which specifies where the in the map’s stack the item should be rendered.This setting is only used when
stackingPosition()
is StackBelowMapLayer or StackAboveMapLayer.See also
See also
Added in version 3.6.
- Parameters:
layer (Optional[QgsMapLayer])
- setStackingPosition(self, position: QgsLayoutItemMapItem.StackingPosition)[source]¶
Sets the item’s stacking
position
, which specifies where the in the map’s stack the item should be rendered.See also
See also
Added in version 3.6.
- Parameters:
position (QgsLayoutItemMapItem.StackingPosition)
- stackingLayer(self) QgsMapLayer | None [source]¶
Returns the item’s stacking layer, which specifies where the in the map’s stack the item should be rendered.
This setting is only used when
stackingPosition()
is StackBelowMapLayer or StackAboveMapLayer.See also
See also
Added in version 3.6.
- Return type:
Optional[QgsMapLayer]
- stackingPosition(self) QgsLayoutItemMapItem.StackingPosition [source]¶
Returns the item’s stacking position, which specifies where the in the map’s stack the item should be rendered.
See also
See also
Added in version 3.6.
- Return type:
- usesAdvancedEffects(self) bool [source]¶
Returns
True
if the item is drawn using advanced effects, such as blend modes.- Return type:
bool
- writeXml(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) bool [source]¶
Stores map item state in a DOM element, where
element
is the DOM element corresponding to a ‘LayoutMap’ tag.See also
- Parameters:
element (QDomElement)
document (QDomDocument)
context (QgsReadWriteContext)
- Return type:
bool