Subgroup: Layout

Class: QgsLayoutItemMap

class qgis.core.QgsLayoutItemMap

Bases: qgis._core.QgsLayoutItem

Layout graphical items for displaying a map.

New in version 3.0: Methods

acceptDrops
acceptHoverEvents
acceptTouchEvents
acceptedMouseButtons
adjustPointForReferencePosition
advance
applyDataDefinedSize
applyItemSizeConstraint
assignFreeId Sets the map id() to a number not yet used in the layout.
atlasDriven Returns whether the map extent is set to follow the current atlas feature.
atlasMargin Returns the margin size (percentage) used when the map is in atlas mode.
atlasScalingMode Returns the current atlas scaling mode.
attemptMove Attempts to move the item to a specified point.
attemptMoveBy Attempts to shift the item’s position by a specified deltaX and deltaY, in layout units.
attemptResize Attempts to resize the item to a specified target size.
attemptSetSceneRect Attempts to update the item’s position and size to match the passed rect in layout coordinates.
backgroundColor Returns the background color for this item.
beginCommand Starts new undo command for this item.
blendMode Returns the item’s composition blending mode.
blockSignals
boundingRect
boundingRegion
boundingRegionGranularity
brush
cacheMode
cancelCommand Cancels the current item command and discards it.
childEvent
childItems
children
childrenBoundingRect
cleanup Called just before a batch of items are deleted, allowing them to run cleanup tasks.
clearFocus
clipPath
collidesWithItem
collidesWithPath
collidingItems
commonAncestorItem
connectNotify
contains
containsAdvancedEffects
containsWmsLayer Returns true if the map contains a WMS layer.
contextMenuEvent
create Returns a new map item for the specified layout.
createCommand
createExpressionContext
crs Returns coordinate reference system used for rendering the map.
cursor
customEvent
customProperties Return list of keys stored in custom properties for the object.
customProperty Read a custom property from the object.
data
dataDefinedProperties Returns a reference to the object’s property collection, used for data defined overrides.
deleteLater
deviceTransform
disconnect
disconnectNotify
displayName
dragEnterEvent
dragLeaveEvent
dragMoveEvent
draw
drawAnnotations Returns whether annotations are drawn within the composer map.
drawBackground
drawDebugRect
drawFrame
dropEvent
dumpObjectInfo
dumpObjectTree
dynamicPropertyNames
effectiveOpacity
endCommand Completes the current item command and push it onto the layout’s undo stack.
ensureVisible ensureVisible(self, float, float, float, float, xMargin: int = 50, yMargin: int = 50)
estimatedFrameBleed Returns the estimated amount the item’s frame bleeds outside the item’s actual rectangle.
event
eventFilter
excludeFromExports Returns whether the item should be excluded from layout exports and prints.
extent Returns the current map extent.
filtersChildEvents
finalizeRestoreFromXml
findChild findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject
findChildren findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject]
fixedSize Returns the fixed size of the item, if applicable, or an empty size if item can be freely resized.
flags
focusInEvent
focusItem
focusOutEvent
focusProxy
followVisibilityPreset Returns whether the map should follow a map theme.
followVisibilityPresetName Preset name that decides which layers and layer styles are used for map rendering.
frameEnabled Returns true if the item includes a frame.
frameJoinStyle Returns the join style used for drawing the item’s frame.
frameStrokeColor Returns the frame’s stroke color.
frameStrokeWidth Returns the frame’s stroke width.
grabKeyboard
grabMouse
graphicsEffect
grid Returns the map item’s first grid.
grids Returns the map item’s grid stack, which is used to control how grids are drawn over the map’s contents.
group
hasBackground Returns true if the item has a background.
hasCursor
hasFocus
hide
hoverEnterEvent
hoverLeaveEvent
hoverMoveEvent
icon
id Returns the item’s ID name.
inherits
inputMethodEvent
inputMethodHints
inputMethodQuery
installEventFilter
installSceneEventFilter
invalidateCache
isActive
isAncestorOf
isBlockedByModalPanel
isClipped
isDrawing True if a draw is already in progress
isEnabled
isGroupMember Returns true if the item is part of a QgsLayoutItemGroup group.
isLocked Returns true if the item is locked, and cannot be interacted with using the mouse.
isObscured isObscured(self, float, float, float, float) -> bool
isObscuredBy
isPanel
isSelected
isSignalConnected
isUnderMouse
isVisible
isVisibleTo
isWidget
isWidgetType
isWindow
isWindowType
itemChange
itemOpacity Returns the item’s opacity.
itemRotation Returns the current rotation for the item, in degrees clockwise.
itemTransform
keepLayerSet Returns whether a stored layer set should be used or the current layer set from the project associated with the layout.
keepLayerStyles Returns whether current styles of layers should be overridden by previously stored styles.
keyPressEvent
keyReleaseEvent
killTimer
layerStyleOverrides Returns stored overrides of styles for layers.
layers Returns the stored layer set.
layout Returns the layout the object is attached to.
mapFromItem mapFromItem(self, QGraphicsItem, QRectF) -> QPolygonF
mapFromParent mapFromParent(self, QRectF) -> QPolygonF
mapFromScene mapFromScene(self, QRectF) -> QPolygonF
mapRectFromItem mapRectFromItem(self, QGraphicsItem, float, float, float, float) -> QRectF
mapRectFromParent mapRectFromParent(self, float, float, float, float) -> QRectF
mapRectFromScene mapRectFromScene(self, float, float, float, float) -> QRectF
mapRectToItem mapRectToItem(self, QGraphicsItem, float, float, float, float) -> QRectF
mapRectToParent mapRectToParent(self, float, float, float, float) -> QRectF
mapRectToScene mapRectToScene(self, float, float, float, float) -> QRectF
mapRotation Returns the rotation used for drawing the map within the composer item, in degrees clockwise.
mapSettings Return map settings that will be used for drawing of the map.
mapToItem mapToItem(self, QGraphicsItem, QRectF) -> QPolygonF
mapToItemCoords Transforms map coordinates to item coordinates (considering rotation and move offset)
mapToParent mapToParent(self, QRectF) -> QPolygonF
mapToScene mapToScene(self, QRectF) -> QPolygonF
mapUnitsToLayoutUnits Returns the conversion factor from map units to layout units.
metaObject
minimumSize Returns the minimum allowed size of the item, if applicable, or an empty size if item can be freely resized.
mouseDoubleClickEvent
mouseMoveEvent
mousePressEvent
mouseReleaseEvent
moveBy
moveContent
moveToThread
numberExportLayers
objectName
opacity
opaqueArea
overview Returns the map item’s first overview.
overviews Returns the map item’s overview stack, which is used to control how overviews are drawn over the map’s contents.
page Returns the page the item is currently on, with the first page returning 0.
pagePos Returns the item’s position (in layout units) relative to the top left corner of its current page.
pagePositionWithUnits Returns the item’s position (in item units) relative to the top left corner of its current page.
paint
panel
panelModality
parent
parentGroup Returns the item’s parent group, if the item is part of a QgsLayoutItemGroup group.
parentItem
parentObject
parentWidget
pen
pos
positionAtReferencePoint
positionWithUnits Returns the item’s current position, including units.
prepareGeometryChange
presetCrs Returns the map’s preset coordinate reference system.
property
propertyDefinitions Returns the layout object property definitions.
pyqtConfigure Each keyword argument is either the name of a Qt property or a Qt signal.
readObjectPropertiesFromElement
readPropertiesFromElement
readXml Sets the item state from a DOM element.
receivers
rect
rectWithFrame Returns the item’s rectangular bounds, including any bleed caused by the item’s frame.
redraw Triggers a redraw (update) of the item.
referencePoint Returns the reference point for positioning of the layout item.
refresh
refreshBackgroundColor
refreshBlendMode
refreshDataDefinedProperty
refreshFrame
refreshItemPosition
refreshItemRotation
refreshItemSize
refreshOpacity
removeCustomProperty Remove a custom property from the object.
removeEventFilter
removeSceneEventFilter
requestedExtent Calculates the extent to request and the yShift of the top-left point in case of rotation.
requiresRasterization
resetTransform
rotateItem Rotates the item by a specified angle in degrees clockwise around a specified reference point.
rotation
scale Returns the map scale.
scene
sceneBoundingRect
sceneEvent
sceneEventFilter
scenePos
sceneTransform
scroll
sender
senderSignalIndex
setAcceptDrops
setAcceptHoverEvents
setAcceptTouchEvents
setAcceptedMouseButtons
setActive
setAtlasDriven Sets whether the map extent will follow the current atlas feature.
setAtlasMargin Sets the margin size (percentage) used when the map is in atlas mode.
setAtlasScalingMode Sets the current atlas scaling mode.
setBackgroundColor Sets the background color for this item.
setBackgroundEnabled Sets whether this item has a background drawn under it or not.
setBlendMode Sets the item’s composition blending mode.
setBoundingRegionGranularity
setBrush
setCacheMode
setCrs Sets the map’s preset crs (coordinate reference system).
setCursor
setCustomProperty Set a custom property for the object.
setData
setDataDefinedProperties Sets the objects’s property collection, used for data defined overrides.
setDrawAnnotations Sets whether annotations are drawn within the composer map.
setEnabled
setExcludeFromExports Sets whether the item should be excluded from layout exports and prints.
setExtent Sets a new extent for the map.
setFiltersChildEvents
setFixedSize
setFlag
setFlags
setFocus
setFocusProxy
setFollowVisibilityPreset Sets whether the map should follow a map theme.
setFollowVisibilityPresetName Sets preset name for map rendering.
setFrameEnabled Sets whether this item has a frame drawn around it or not.
setFrameJoinStyle Sets the join style used when drawing the item’s frame.
setFrameStrokeColor Sets the frame stroke color.
setFrameStrokeWidth
setGraphicsEffect
setGroup
setId Set the item’s id name.
setInputMethodHints
setItemOpacity Sets the item’s opacity.
setItemRotation Sets the layout item’s rotation, in degrees clockwise.
setKeepLayerSet Sets whether the stored layer set should be used or the current layer set of the associated project.
setKeepLayerStyles Sets whether current styles of layers should be overridden by previously stored styles.
setLayerStyleOverrides Sets the stored overrides of styles for layers.
setLayers Sets the stored layers set.
setLocked Sets whether the item is locked, preventing mouse interactions with the item.
setMapRotation Sets the rotation for the map - this does not affect the composer item shape, only the way the map is drawn within the item.
setMinimumSize
setMoveContentPreviewOffset
setObjectName
setOpacity
setPanelModality
setParent
setParentGroup Sets the item’s parent group.
setParentItem
setPen
setPos setPos(self, float, float)
setProperty
setRect setRect(self, float, float, float, float)
setReferencePoint Sets the reference point for positioning of the layout item.
setRotation
setScale Sets new map scale and changes only the map extent.
setSelected Sets whether the item should be selected.
setToolTip
setTransform
setTransformOriginPoint setTransformOriginPoint(self, float, float)
setTransformations
setVisibility Sets whether the item is visible.
setVisible
setX
setY
setZValue
shape
shouldDrawItem Returns whether the item should be drawn in the current context.
show
signalsBlocked
sizeWithUnits Returns the item’s current size, including units.
stackBefore
startTimer
storeCurrentLayerStyles Stores the current project layer styles into style overrides.
templateUuid Returns the item’s original identification string.
thread
timerEvent
toGraphicsObject
toolTip
topLeftToReferencePoint
topLevelItem
topLevelWidget
tr
transform
transformOriginPoint
transformations
transformedMapPolygon Returns extent that considers rotation and shift with mOffsetX / mOffsetY
type
ungrabKeyboard
ungrabMouse
unsetCursor
update update(self, float, float, float, float)
updateBoundingRect Updates the bounding rect of this item.
updateMicroFocus
uuid Returns the item identification string.
visibleExtentPolygon Returns a polygon representing the current visible map extent, considering map extents and rotation.
wheelEvent
window
writeObjectPropertiesToElement
writePropertiesToElement
writeXml Stores the item state in a DOM element.
x
y
zValue
zoomContent
zoomToExtent Zooms the map so that the specified extent is fully visible within the map item.

Attributes

AllProperties
Auto
BackgroundColor
BlendMode
DeviceCoordinateCache
EvaluatedValue
ExcludeFromExports
Fixed
FrameColor
ItemAcceptsInputMethod
ItemChildAddedChange
ItemChildRemovedChange
ItemClipsChildrenToShape
ItemClipsToShape
ItemContainsChildrenInShape
ItemCoordinateCache
ItemCursorChange
ItemCursorHasChanged
ItemDoesntPropagateOpacityToChildren
ItemEnabledChange
ItemEnabledHasChanged
ItemFlagsChange
ItemFlagsHaveChanged
ItemHasNoContents
ItemHeight
ItemIgnoresParentOpacity
ItemIgnoresTransformations
ItemIsFocusable
ItemIsMovable
ItemIsPanel
ItemIsSelectable
ItemMatrixChange
ItemNegativeZStacksBehindParent
ItemOpacityChange
ItemOpacityHasChanged
ItemParentChange
ItemParentHasChanged
ItemPositionChange
ItemPositionHasChanged
ItemRotation
ItemRotationChange
ItemRotationHasChanged
ItemScaleChange
ItemScaleHasChanged
ItemSceneChange
ItemSceneHasChanged
ItemScenePositionHasChanged
ItemSelectedChange
ItemSelectedHasChanged
ItemSendsGeometryChanges
ItemSendsScenePositionChanges
ItemStacksBehindParent
ItemToolTipChange
ItemToolTipHasChanged
ItemTransformChange
ItemTransformHasChanged
ItemTransformOriginPointChange
ItemTransformOriginPointHasChanged
ItemUsesExtendedStyleOption
ItemVisibleChange
ItemVisibleHasChanged
ItemWidth
ItemZValueChange
ItemZValueHasChanged
LegendColumnCount
LegendTitle
LowerLeft
LowerMiddle
LowerRight
MapAtlasMargin
MapLayers
MapRotation
MapScale
MapStylePreset
MapXMax
MapXMin
MapYMax
MapYMin
Middle
MiddleLeft
MiddleRight
NoCache
NoProperty
NonModal
NumPages
Opacity
OriginalValue
PageNumber
PanelModal
PaperHeight
PaperOrientation
PaperWidth
PictureSource
PictureSvgBackgroundColor
PictureSvgStrokeColor
PictureSvgStrokeWidth
PositionX
PositionY
Predefined
PresetPaperSize
ScalebarFillColor
ScalebarFillColor2
ScalebarLineColor
ScalebarLineWidth
SceneModal
SourceUrl
TestProperty
Transparency
Type
UndoArrowHeadFillColor
UndoArrowHeadStrokeColor
UndoArrowHeadWidth
UndoArrowStrokeWidth
UndoAtlasMargin
UndoBackgroundColor
UndoCustomCommand
UndoGridFramePenColor
UndoIncrementalMove
UndoIncrementalResize
UndoLabelFont
UndoLabelFontColor
UndoLabelMargin
UndoLabelText
UndoLegendBoxSpace
UndoLegendColumnCount
UndoLegendColumnSpace
UndoLegendFontColor
UndoLegendGroupFont
UndoLegendGroupSpace
UndoLegendIconSymbolSpace
UndoLegendItemFont
UndoLegendLayerFont
UndoLegendLayerSpace
UndoLegendLineSpacing
UndoLegendRasterStrokeColor
UndoLegendRasterStrokeWidth
UndoLegendSymbolHeight
UndoLegendSymbolSpace
UndoLegendSymbolWidth
UndoLegendText
UndoLegendTitleFont
UndoLegendTitleSpaceBottom
UndoLegendWmsLegendHeight
UndoLegendWmsLegendWidth
UndoMapAnnotationDistance
UndoMapGridAnnotationFontColor
UndoMapGridFrameFill1Color
UndoMapGridFrameFill2Color
UndoMapGridLineSymbol
UndoMapGridMarkerSymbol
UndoMapRotation
UndoNodeMove
UndoNone
UndoOpacity
UndoOverviewStyle
UndoPictureFillColor
UndoPictureNorthOffset
UndoPictureRotation
UndoPictureStrokeColor
UndoPictureStrokeWidth
UndoRotation
UndoScaleBarBoxContentSpace
UndoScaleBarFillColor
UndoScaleBarFillColor2
UndoScaleBarFontColor
UndoScaleBarHeight
UndoScaleBarLabelBarSize
UndoScaleBarLineWidth
UndoScaleBarMapUnitsSegment
UndoScaleBarSegmentSize
UndoScaleBarSegments
UndoScaleBarSegmentsLeft
UndoScaleBarStrokeColor
UndoScaleBarUnitText
UndoSetId
UndoShapeCornerRadius
UndoShapeStyle
UndoStrokeColor
UndoStrokeWidth
UndoZoomContent
UpperLeft
UpperMiddle
UpperRight
UserType
changed Emitted when the object’s properties change.
destroyed destroyed(self, QObject = None) [signal]
extentChanged Is emitted when the map’s extent changes.
frameChanged Emitted if the item’s frame style changes.
layerStyleOverridesChanged Emitted when layer style overrides are changed…
lockChanged Emitted if the item’s lock status changes.
mapRotationChanged Is emitted when the map’s rotation changes.
objectNameChanged objectNameChanged(self, str) [signal]
preparedForAtlas Is emitted when the map has been prepared for atlas rendering, just before actual rendering [signal]
rotationChanged Emitted on item rotation change.
sizePositionChanged Emitted when the item’s size or position changes.
staticMetaObject
class AtlasScalingMode

Bases: int

Auto = 2
Fixed = 0
Predefined = 1
adjustPointForReferencePosition()
applyDataDefinedSize()
applyItemSizeConstraint()
assignFreeId(self)

Sets the map id() to a number not yet used in the layout. The existing id() is kept if it is not in use.

atlasDriven(self) → bool

Returns whether the map extent is set to follow the current atlas feature.

Returns:true if map will follow the current atlas feature.

See also

setAtlasDriven()

atlasMargin(self, valueType: QgsLayoutObject.PropertyValueType = QgsLayoutObject.EvaluatedValue) → float

Returns the margin size (percentage) used when the map is in atlas mode.

Parameters:valueType – controls whether the returned value is the user specified atlas margin,

or the current evaluated atlas margin (which may be affected by data driven atlas margin settings).

Returns:margin size in percentage to leave around the atlas feature’s extent

Note

this is only used if atlasScalingMode() is Auto.

See also

setAtlasMargin()

atlasScalingMode(self) → QgsLayoutItemMap.AtlasScalingMode

Returns the current atlas scaling mode. This controls how the map’s extents are calculated for the current atlas feature when an atlas composition is enabled.

Returns:the current scaling mode

Note

this parameter is only used if atlasDriven() is true

See also

atlasDriven()

boundingRect(self) → QRectF
childEvent()
connectNotify()
containsAdvancedEffects(self) → bool
containsWmsLayer(self) → bool

Returns true if the map contains a WMS layer.

contextMenuEvent()
create(layout: QgsLayout) → QgsLayoutItemMap

Returns a new map item for the specified layout.

The caller takes responsibility for deleting the returned object.

createExpressionContext(self) → QgsExpressionContext
crs(self) → QgsCoordinateReferenceSystem

Returns coordinate reference system used for rendering the map. This will match the presetCrs() if that is set, or if a preset CRS is not set then the map’s CRS will follow the composition’s project’s CRS.

See also

presetCrs()

See also

setCrs()

customEvent()
disconnectNotify()
displayName(self) → str
dragEnterEvent()
dragLeaveEvent()
dragMoveEvent()
draw(self, context: QgsRenderContext, itemStyle: QStyleOptionGraphicsItem = None)
drawAnnotations(self) → bool

Returns whether annotations are drawn within the composer map.

drawBackground()
drawDebugRect()
drawFrame()
dropEvent()
extent(self) → QgsRectangle

Returns the current map extent.

See also

extentChanged()

extentChanged

Is emitted when the map’s extent changes.

See also

setExtent()

See also

extent() [signal]

finalizeRestoreFromXml(self)
focusInEvent()
focusOutEvent()
followVisibilityPreset(self) → bool

Returns whether the map should follow a map theme. If true, the layers and layer styles will be used from given preset name (configured with setFollowVisibilityPresetName() method). This means when preset’s settings are changed, the new settings are automatically picked up next time when rendering, without having to explicitly update them. At most one of the flags keepLayerSet() and followVisibilityPreset() should be enabled at any time since they are alternative approaches - if both are enabled, following map theme has higher priority. If neither is enabled (or if preset name is not set), map will use the same configuration as the map canvas uses.

followVisibilityPresetName(self) → str

Preset name that decides which layers and layer styles are used for map rendering. It is only used when followVisibilityPreset() returns true.

grid(self) → QgsLayoutItemMapGrid

Returns the map item’s first grid. This is a convenience function.

See also

grids()

grids(self) → QgsLayoutItemMapGridStack

Returns the map item’s grid stack, which is used to control how grids are drawn over the map’s contents.

See also

grid()

hoverEnterEvent()
hoverLeaveEvent()
hoverMoveEvent()
icon(self) → QIcon
inputMethodEvent()
inputMethodQuery()
invalidateCache(self)
isDrawing(self) → bool

True if a draw is already in progress

isSignalConnected()
itemChange()
keepLayerSet(self) → bool

Returns whether a stored layer set should be used or the current layer set from the project associated with the layout. This is just a GUI flag, and itself does not change which layers are rendered in the map. Instead, use setLayers() to control which layers are rendered.

See also

layers()

keepLayerStyles(self) → bool

Returns whether current styles of layers should be overridden by previously stored styles.

keyPressEvent()
keyReleaseEvent()
layerStyleOverrides(self) → Dict[str, str]

Returns stored overrides of styles for layers.

layerStyleOverridesChanged

Emitted when layer style overrides are changed… a means to let associated legend items know they should update [signal]

layers(self) → List[QgsMapLayer]

Returns the stored layer set. If empty, the current project layers will be used instead.

See also

setLayers()

See also

keepLayerSet()

mapRotation(self, valueType: QgsLayoutObject.PropertyValueType = QgsLayoutObject.EvaluatedValue) → float

Returns the rotation used for drawing the map within the composer item, in degrees clockwise.

Parameters:valueType – controls whether the returned value is the user specified rotation,

or the current evaluated rotation (which may be affected by data driven rotation settings).

See also

setMapRotation()

mapRotationChanged

Is emitted when the map’s rotation changes.

See also

setMapRotation()

See also

mapRotation() [signal]

mapSettings(self, extent: QgsRectangle, size: QSizeF, dpi: float) → QgsMapSettings

Return map settings that will be used for drawing of the map.

mapToItemCoords(self, mapCoords: Union[QPointF, QPoint]) → QPointF

Transforms map coordinates to item coordinates (considering rotation and move offset)

mapUnitsToLayoutUnits(self) → float

Returns the conversion factor from map units to layout units. This is calculated using the width of the map item and the width of the current visible map extent.

mouseDoubleClickEvent()
mouseMoveEvent()
mousePressEvent()
mouseReleaseEvent()
moveContent(self, dx: float, dy: float)
numberExportLayers(self) → int
overview(self) → QgsLayoutItemMapOverview

Returns the map item’s first overview. This is a convenience function.

Returns:pointer to first overview for map item

See also

overviews()

overviews(self) → QgsLayoutItemMapOverviewStack

Returns the map item’s overview stack, which is used to control how overviews are drawn over the map’s contents.

Returns:pointer to overview stack

See also

overview()

paint(self, painter: QPainter, itemStyle: QStyleOptionGraphicsItem, pWidget: QWidget)
positionAtReferencePoint()
prepareGeometryChange()
preparedForAtlas

Is emitted when the map has been prepared for atlas rendering, just before actual rendering [signal]

presetCrs(self) → QgsCoordinateReferenceSystem

Returns the map’s preset coordinate reference system. If set, this CRS will be used to render the map regardless of any project CRS setting. If the returned CRS is not valid then the project CRS will be used to render the map.

See also

crs()

See also

setCrs()

readObjectPropertiesFromElement()
readPropertiesFromElement(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool
receivers()
refresh(self)
refreshBackgroundColor()
refreshBlendMode()
refreshDataDefinedProperty(self, property: QgsLayoutObject.DataDefinedProperty = QgsLayoutObject.AllProperties)
refreshFrame()
refreshItemPosition()
refreshItemRotation()
refreshItemSize()
refreshOpacity()
requestedExtent(self) → QgsRectangle

Calculates the extent to request and the yShift of the top-left point in case of rotation.

requiresRasterization(self) → bool
scale(self) → float

Returns the map scale. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.

See also

setScale()

sceneEvent()
sceneEventFilter()
sender()
senderSignalIndex()
setAtlasDriven(self, enabled: bool)

Sets whether the map extent will follow the current atlas feature.

Parameters:enabled – set to true if the map extents should be set by the current atlas feature.

See also

atlasDriven()

setAtlasMargin(self, margin: float)

Sets the margin size (percentage) used when the map is in atlas mode.

Parameters:margin – size in percentage to leave around the atlas feature’s extent

Note

this is only used if atlasScalingMode() is Auto.

See also

atlasMargin()

setAtlasScalingMode(self, mode: QgsLayoutItemMap.AtlasScalingMode)

Sets the current atlas scaling mode. This controls how the map’s extents are calculated for the current atlas feature when an atlas composition is enabled.

Parameters:mode – atlas scaling mode to set

Note

this parameter is only used if atlasDriven() is true

See also

atlasDriven()

setCrs(self, crs: QgsCoordinateReferenceSystem)

Sets the map’s preset crs (coordinate reference system). If a valid CRS is set, this CRS will be used to render the map regardless of any project CRS setting. If the CRS is not valid then the project CRS will be used to render the map.

See also

crs()

See also

presetCrs()

setDrawAnnotations(self, draw: bool)

Sets whether annotations are drawn within the composer map.

setExtent(self, extent: QgsRectangle)

Sets a new extent for the map. This method may change the width or height of the map item to ensure that the extent exactly matches the specified extent, with no overlap or margin. This method implicitly alters the map scale.

See also

zoomToExtent()

See also

extentChanged()

setFixedSize()
setFollowVisibilityPreset(self, follow: bool)

Sets whether the map should follow a map theme. See followVisibilityPreset() for more details.

setFollowVisibilityPresetName(self, name: str)

Sets preset name for map rendering. See followVisibilityPresetName() for more details.

setFrameStrokeWidth(self, width: QgsLayoutMeasurement)
setKeepLayerSet(self, enabled: bool)

Sets whether the stored layer set should be used or the current layer set of the associated project. This is just a GUI flag, and itself does not change which layers are rendered in the map. Instead, use setLayers() to control which layers are rendered.

See also

keepLayerSet()

See also

layers()

setKeepLayerStyles(self, enabled: bool)

Sets whether current styles of layers should be overridden by previously stored styles.

setLayerStyleOverrides(self, overrides: Dict[str, str])

Sets the stored overrides of styles for layers.

setLayers(self, layers: Iterable[QgsMapLayer])

Sets the stored layers set. If empty, the current project layers will be used instead.

See also

layers()

See also

keepLayerSet()

setMapRotation(self, rotation: float)

Sets the rotation for the map - this does not affect the composer item shape, only the way the map is drawn within the item. Rotation is in degrees, clockwise.

See also

mapRotation()

setMinimumSize()
setMoveContentPreviewOffset(self, dx: float, dy: float)
setScale(self, scale: float, forceUpdate: bool = True)

Sets new map scale and changes only the map extent.

The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.

See also

scale()

storeCurrentLayerStyles(self)

Stores the current project layer styles into style overrides.

timerEvent()
topLeftToReferencePoint()
transformedMapPolygon(self) → QPolygonF

Returns extent that considers rotation and shift with mOffsetX / mOffsetY

type(self) → int
updateBoundingRect(self)

Updates the bounding rect of this item. Call this function before doing any changes related to annotation out of the map rectangle

updateMicroFocus()
visibleExtentPolygon(self) → QPolygonF

Returns a polygon representing the current visible map extent, considering map extents and rotation. If the map rotation is 0, the result is the same as currentMapExtent

Returns:polygon with the four corner points representing the visible map extent. The points are

clockwise, starting at the top-left point

See also

extent()

wheelEvent()
writeObjectPropertiesToElement()
writePropertiesToElement(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) → bool
zoomContent(self, factor: float, point: Union[QPointF, QPoint])
zoomToExtent(self, extent: QgsRectangle)

Zooms the map so that the specified extent is fully visible within the map item. This method will not change the width or height of the map, and may result in an overlap or margin from the specified extent. This method implicitly alters the map scale.

See also

setExtent()