QgsLayoutItemMapGrid class

An individual grid which is drawn above the map content in a QgsLayoutItemMap.

Base classes

class QgsLayoutItemMapItem
An item which is drawn inside a QgsLayoutItemMap, e.g., a grid or map overview.

Public types

enum AnnotationCoordinate { Longitude = 0, Latitude }
Annotation coordinate type.
enum AnnotationDirection { Horizontal = 0, Vertical, VerticalDescending, BoundaryDirection }
Direction of grid annotations.
enum AnnotationFormat { Decimal = 0, DegreeMinute, DegreeMinuteSecond, DecimalWithSuffix, DegreeMinuteNoSuffix, DegreeMinutePadded, DegreeMinuteSecondNoSuffix, DegreeMinuteSecondPadded, CustomFormat }
Format for displaying grid annotations.
enum AnnotationPosition { InsideMapFrame = 0, OutsideMapFrame }
Position for grid annotations.
enum BorderSide { Left, Right, Bottom, Top }
Border sides for annotations.
enum DisplayMode { ShowAll = 0, LatitudeOnly, LongitudeOnly, HideAll }
Display settings for grid annotations and frames.
enum FrameSideFlag { FrameLeft = 0x01, FrameRight = 0x02, FrameTop = 0x04, FrameBottom = 0x08 }
Flags for controlling which side of the map a frame is drawn on.
enum FrameStyle { NoFrame = 0, Zebra, InteriorTicks, ExteriorTicks, InteriorExteriorTicks, LineBorder, LineBorderNautical, ZebraNautical }
Style for grid frame.
enum GridStyle { Solid = 0, Cross, Markers, FrameAnnotationsOnly }
Grid drawing style.
enum GridUnit { MapUnit, MM, CM }
Unit for grid values.

Constructors, destructors, conversion operators

QgsLayoutItemMapGrid(const QString& name, QgsLayoutItemMap* map)
Constructor for QgsLayoutItemMapGrid.

Public functions

auto annotationDirection(BorderSide border) const -> AnnotationDirection
Returns the direction for drawing frame annotations, on the specified side of the map.
auto annotationDisplay(BorderSide border) const -> DisplayMode
Returns the display mode for the grid annotations on a specified side of the map frame.
auto annotationEnabled() const -> bool
Returns whether annotations are shown for the grid.
auto annotationExpression() const -> QString
Returns the expression used for drawing grid annotations.
auto annotationFont() const -> QFont
Returns the font used for drawing grid annotations.
auto annotationFontColor() const -> QColor
Returns the font color used for drawing grid annotations.
auto annotationFormat() const -> AnnotationFormat
Returns the format for drawing grid annotations.
auto annotationFrameDistance() const -> double
Returns the distance between the map frame and annotations.
auto annotationPosition(BorderSide side) const -> AnnotationPosition
Returns the position for the grid annotations on a specified side of the map frame.
auto annotationPrecision() const -> int
Returns the coordinate precision for grid annotations, which is the number of decimal places shown when drawing grid annotations.
auto blendMode() const -> QPainter::CompositionMode
Retrieves the blending mode used for drawing the grid.
void calculateMaxExtension(double& top, double& right, double& bottom, double& left) const
Calculates the maximum distance the grid extends beyond the QgsLayoutItemMap's item rect.
auto createExpressionContext() const -> QgsExpressionContext override
This method needs to be reimplemented in all classes which implement this interface and return an expression context.
auto crossLength() const -> double
Retrieves the length (in layout units) of the cross segments drawn for the grid.
auto crs() const -> QgsCoordinateReferenceSystem
Retrieves the CRS for the grid.
void draw(QPainter* painter) override
Draws the item on to a destination painter.
auto frameDivisions(BorderSide side) const -> DisplayMode
Returns the type of grid divisions which are used for frames on a specified side of the map.
auto frameFillColor1() const -> QColor
Retrieves the first fill color for the grid frame.
auto frameFillColor2() const -> QColor
Retrieves the second fill color for the grid frame.
auto frameMargin() const -> double
Sets the grid frame Margin (in layout units).
auto framePenColor() const -> QColor
Retrieves the color of the stroke drawn in the grid frame.
auto framePenSize() const -> double
Retrieves the width of the stroke drawn in the grid frame.
auto frameSideFlags() const -> QgsLayoutItemMapGrid::FrameSideFlags
Returns the flags which control which sides of the map item the grid frame is drawn on.
auto frameStyle() const -> FrameStyle
Returns the grid frame style.
auto frameWidth() const -> double
Gets the grid frame width in layout units.
auto intervalX() const -> double
Returns the interval between grid lines in the x-direction.
auto intervalY() const -> double
Returns the interval between grid lines in the y-direction.
auto lineSymbol() const -> const QgsLineSymbol*
Returns the line symbol used for drawing grid lines.
auto lineSymbol() -> QgsLineSymbol*
Returns the line symbol used for drawing grid lines.
auto markerSymbol() const -> const QgsMarkerSymbol*
Returns the marker symbol used for drawing grid points.
auto markerSymbol() -> QgsMarkerSymbol*
Returns the marker symbol used for drawing grid points.
auto maxExtension() const -> double
Calculates the maximum distance the grid extends beyond the QgsLayoutItemMap's item rect (in layout units).
auto offsetX() const -> double
Returns the offset for grid lines in the x-direction.
auto offsetY() const -> double
Returns the offset for grid lines in the y-direction.
auto readXml(const QDomElement& element, const QDomDocument& doc, const QgsReadWriteContext& context) -> bool override
Sets the map item state from a DOM document, where element is the DOM node corresponding to a 'LayoutMapGrid' tag.
void setAnnotationDirection(AnnotationDirection direction, BorderSide side)
Sets the direction for drawing frame annotations for the specified map side.
void setAnnotationDirection(AnnotationDirection direction)
Sets the direction for drawing all frame annotations.
void setAnnotationDisplay(DisplayMode display, BorderSide border)
Sets what types of grid annotations should be drawn for a specified side of the map frame, or whether grid annotations should be disabled for the side.
void setAnnotationEnabled(const bool enabled)
Sets whether annotations should be shown for the grid.
void setAnnotationExpression(const QString& expression)
Sets the expression used for drawing grid annotations.
void setAnnotationFont(const QFont& font)
Sets the font used for drawing grid annotations.
void setAnnotationFontColor(const QColor& color)
Sets the font color used for drawing grid annotations.
void setAnnotationFormat(const AnnotationFormat format)
Sets the format for drawing grid annotations.
void setAnnotationFrameDistance(const double distance)
Sets the distance between the map frame and annotations.
void setAnnotationPosition(AnnotationPosition position, BorderSide side)
Sets the position for the grid annotations on a specified side of the map frame.
void setAnnotationPrecision(const int precision)
Sets the coordinate precision for grid annotations.
void setBlendMode(const QPainter::CompositionMode mode)
Sets the blending mode used for drawing the grid.
void setCrossLength(const double length)
Sets the length (in layout units) of the cross segments drawn for the grid.
void setCrs(const QgsCoordinateReferenceSystem& crs)
Sets the crs for the grid.
void setFrameDivisions(DisplayMode divisions, BorderSide side)
Sets what type of grid divisions should be used for frames on a specified side of the map.
void setFrameFillColor1(const QColor& color)
Sets the first fill color used for the grid frame.
void setFrameFillColor2(const QColor& color)
Sets the second fill color used for the grid frame.
void setFrameMargin(const double margin)
Sets the grid frame margin (in layout units).
void setFramePenColor(const QColor& color)
Sets the color of the stroke drawn in the grid frame.
void setFramePenSize(const double width)
Sets the width of the stroke drawn in the grid frame.
void setFrameSideFlag(QgsLayoutItemMapGrid::FrameSideFlag flag, bool on = true)
Sets whether the grid frame is drawn for a certain side of the map item.
void setFrameSideFlags(QgsLayoutItemMapGrid::FrameSideFlags flags)
Sets flags for grid frame sides.
void setFrameStyle(const FrameStyle style)
Sets the grid frame style.
void setFrameWidth(const double width)
Sets the grid frame width (in layout units).
void setGridLineColor(const QColor& color)
Sets the color of grid lines.
void setGridLineWidth(double width)
Sets the width of grid lines (in layout units).
void setIntervalX(double interval)
Sets the interval between grid lines in the x-direction.
void setIntervalY(double interval)
Sets the interval between grid lines in the y-direction.
void setLineSymbol(QgsLineSymbol* symbol)
Sets the line symbol used for drawing grid lines.
void setMarkerSymbol(QgsMarkerSymbol* symbol)
Sets the marker symbol used for drawing grid points.
void setOffsetX(double offset)
Sets the offset for grid lines in the x-direction.
void setOffsetY(double offset)
Sets the offset for grid lines in the y-direction.
void setStyle(GridStyle style)
Sets the grid style, which controls how the grid is drawn over the map's contents.
void setUnits(GridUnit unit)
Sets the unit to use for grid measurements such as the interval and offset for grid lines.
auto style() const -> GridStyle
Returns the grid's style, which controls how the grid is drawn over the map's contents.
auto testFrameSideFlag(FrameSideFlag flag) const -> bool
Tests whether the grid frame should be drawn on a specified side of the map item.
auto units() const -> GridUnit
Returns the units used for grid measurements such as the interval and offset for grid lines.
auto usesAdvancedEffects() const -> bool override
Returns true if the item is drawn using advanced effects, such as blend modes.
auto writeXml(QDomElement& element, QDomDocument& document, const QgsReadWriteContext& context) const -> bool override
Stores map item state in a DOM element, where element is the DOM element corresponding to a 'LayoutMap' tag.

Enum documentation

enum QgsLayoutItemMapGrid::AnnotationCoordinate

Annotation coordinate type.

Enumerators
Longitude

Coordinate is a longitude value.

Latitude

Coordinate is a latitude value.

enum QgsLayoutItemMapGrid::AnnotationDirection

Direction of grid annotations.

Enumerators
Horizontal

Draw annotations horizontally.

Vertical

Draw annotations vertically, ascending.

VerticalDescending

Draw annotations vertically, descending.

BoundaryDirection

Annotations follow the boundary direction.

enum QgsLayoutItemMapGrid::AnnotationFormat

Format for displaying grid annotations.

Enumerators
Decimal

Decimal degrees, use - for S/W coordinates.

DegreeMinute

Degree/minutes, use NSEW suffix.

DegreeMinuteSecond

Degree/minutes/seconds, use NSEW suffix.

DecimalWithSuffix

Decimal degrees, use NSEW suffix.

DegreeMinuteNoSuffix

Degree/minutes, use - for S/W coordinates.

DegreeMinutePadded

Degree/minutes, with minutes using leading zeros where required.

DegreeMinuteSecondNoSuffix

Degree/minutes/seconds, use - for S/W coordinates.

DegreeMinuteSecondPadded

Degree/minutes/seconds, with minutes using leading zeros where required.

CustomFormat

Custom expression-based format.

enum QgsLayoutItemMapGrid::AnnotationPosition

Position for grid annotations.

Enumerators
InsideMapFrame

Draw annotations inside the map frame.

OutsideMapFrame

Draw annotations outside the map frame.

enum QgsLayoutItemMapGrid::BorderSide

Border sides for annotations.

Enumerators
Left

Left border.

Right

Right border.

Bottom

Bottom border.

Top

Top border.

enum QgsLayoutItemMapGrid::DisplayMode

Display settings for grid annotations and frames.

Enumerators
ShowAll

Show both latitude and longitude annotations/divisions.

LatitudeOnly

Show latitude/y annotations/divisions only.

LongitudeOnly

Show longitude/x annotations/divisions only.

HideAll

No annotations.

enum QgsLayoutItemMapGrid::FrameSideFlag

Flags for controlling which side of the map a frame is drawn on.

Enumerators
FrameLeft

Left side of map.

FrameRight

Right side of map.

FrameTop

Top side of map.

FrameBottom

Bottom side of map.

enum QgsLayoutItemMapGrid::FrameStyle

Style for grid frame.

Enumerators
NoFrame

Disable grid frame.

Zebra

Black/white pattern.

InteriorTicks

Tick markers drawn inside map frame.

ExteriorTicks

Tick markers drawn outside map frame.

InteriorExteriorTicks

Tick markers drawn both inside and outside the map frame.

LineBorder

Simple solid line frame.

LineBorderNautical

Simple solid line frame, with nautical style diagonals on corners.

ZebraNautical

Black/white pattern, with nautical style diagonals on corners.

enum QgsLayoutItemMapGrid::GridStyle

Grid drawing style.

Enumerators
Solid
Cross

Draw line crosses at intersections of grid lines.

Markers

Draw markers at intersections of grid lines.

FrameAnnotationsOnly

No grid lines over the map, only draw frame and annotations.

enum QgsLayoutItemMapGrid::GridUnit

Unit for grid values.

Enumerators
MapUnit

Grid units follow map units.

MM

Grid units in millimeters.

CM

Grid units in centimeters.

Function documentation

QgsLayoutItemMapGrid::QgsLayoutItemMapGrid(const QString& name, QgsLayoutItemMap* map)

Constructor for QgsLayoutItemMapGrid.

Parameters
name friendly display name for grid
map QgsLayoutItemMap the grid is attached to

AnnotationDirection QgsLayoutItemMapGrid::annotationDirection(BorderSide border) const

Returns the direction for drawing frame annotations, on the specified side of the map.

DisplayMode QgsLayoutItemMapGrid::annotationDisplay(BorderSide border) const

Returns the display mode for the grid annotations on a specified side of the map frame.

Parameters
border side of map for annotations
Returns display mode for grid annotations

This property also specifies whether annotations have been disabled from a side of the map frame.

bool QgsLayoutItemMapGrid::annotationEnabled() const

Returns whether annotations are shown for the grid.

QString QgsLayoutItemMapGrid::annotationExpression() const

Returns the expression used for drawing grid annotations.

This is only used when annotationFormat() is QgsLayoutItemMapGrid::CustomFormat.

QFont QgsLayoutItemMapGrid::annotationFont() const

Returns the font used for drawing grid annotations.

QColor QgsLayoutItemMapGrid::annotationFontColor() const

Returns the font color used for drawing grid annotations.

AnnotationFormat QgsLayoutItemMapGrid::annotationFormat() const

Returns the format for drawing grid annotations.

double QgsLayoutItemMapGrid::annotationFrameDistance() const

Returns the distance between the map frame and annotations.

Units are in layout units.

AnnotationPosition QgsLayoutItemMapGrid::annotationPosition(BorderSide side) const

Returns the position for the grid annotations on a specified side of the map frame.

int QgsLayoutItemMapGrid::annotationPrecision() const

Returns the coordinate precision for grid annotations, which is the number of decimal places shown when drawing grid annotations.

QPainter::CompositionMode QgsLayoutItemMapGrid::blendMode() const

Retrieves the blending mode used for drawing the grid.

void QgsLayoutItemMapGrid::calculateMaxExtension(double& top, double& right, double& bottom, double& left) const

Calculates the maximum distance the grid extends beyond the QgsLayoutItemMap's item rect.

This method calculates the distance for each side of the map item separately.

QgsExpressionContext QgsLayoutItemMapGrid::createExpressionContext() const override

This method needs to be reimplemented in all classes which implement this interface and return an expression context.

double QgsLayoutItemMapGrid::crossLength() const

Retrieves the length (in layout units) of the cross segments drawn for the grid.

This is only used for grids with QgsLayoutItemMapGrid::Cross styles.

QgsCoordinateReferenceSystem QgsLayoutItemMapGrid::crs() const

Retrieves the CRS for the grid.

DisplayMode QgsLayoutItemMapGrid::frameDivisions(BorderSide side) const

Returns the type of grid divisions which are used for frames on a specified side of the map.

QColor QgsLayoutItemMapGrid::frameFillColor1() const

Retrieves the first fill color for the grid frame.

QColor QgsLayoutItemMapGrid::frameFillColor2() const

Retrieves the second fill color for the grid frame.

double QgsLayoutItemMapGrid::frameMargin() const

Sets the grid frame Margin (in layout units).

This property controls distance between the map frame and the grid frame.

QColor QgsLayoutItemMapGrid::framePenColor() const

Retrieves the color of the stroke drawn in the grid frame.

double QgsLayoutItemMapGrid::framePenSize() const

Retrieves the width of the stroke drawn in the grid frame.

QgsLayoutItemMapGrid::FrameSideFlags QgsLayoutItemMapGrid::frameSideFlags() const

Returns the flags which control which sides of the map item the grid frame is drawn on.

FrameStyle QgsLayoutItemMapGrid::frameStyle() const

Returns the grid frame style.

double QgsLayoutItemMapGrid::frameWidth() const

Gets the grid frame width in layout units.

This property controls how wide the grid frame is. The size of the line outlines drawn in the frame can be retrieved via the framePenSize method.

double QgsLayoutItemMapGrid::intervalX() const

Returns the interval between grid lines in the x-direction.

The units are retrieved through the units() method.

double QgsLayoutItemMapGrid::intervalY() const

Returns the interval between grid lines in the y-direction.

The units are retrieved through the units() method.

const QgsLineSymbol* QgsLayoutItemMapGrid::lineSymbol() const

Returns the line symbol used for drawing grid lines.

This is only used for grids with QgsLayoutItemMapGrid::Solid or QgsLayoutItemMapGrid::Cross styles.

QgsLineSymbol* QgsLayoutItemMapGrid::lineSymbol()

Returns the line symbol used for drawing grid lines.

This is only used for grids with QgsLayoutItemMapGrid::Solid or QgsLayoutItemMapGrid::Cross styles.

const QgsMarkerSymbol* QgsLayoutItemMapGrid::markerSymbol() const

Returns the marker symbol used for drawing grid points.

This is only used for grids with a QgsLayoutItemMapGrid::Markers style.

QgsMarkerSymbol* QgsLayoutItemMapGrid::markerSymbol()

Returns the marker symbol used for drawing grid points.

This is only used for grids with a QgsLayoutItemMapGrid::Markers style.

double QgsLayoutItemMapGrid::offsetX() const

Returns the offset for grid lines in the x-direction.

The units are retrieved through the units() method.

double QgsLayoutItemMapGrid::offsetY() const

Returns the offset for grid lines in the y-direction.

The units are retrieved through the units() method.

bool QgsLayoutItemMapGrid::readXml(const QDomElement& element, const QDomDocument& doc, const QgsReadWriteContext& context) override

Sets the map item state from a DOM document, where element is the DOM node corresponding to a 'LayoutMapGrid' tag.

void QgsLayoutItemMapGrid::setAnnotationDirection(AnnotationDirection direction, BorderSide side)

Sets the direction for drawing frame annotations for the specified map side.

void QgsLayoutItemMapGrid::setAnnotationDirection(AnnotationDirection direction)

Sets the direction for drawing all frame annotations.

void QgsLayoutItemMapGrid::setAnnotationDisplay(DisplayMode display, BorderSide border)

Sets what types of grid annotations should be drawn for a specified side of the map frame, or whether grid annotations should be disabled for the side.

Parameters
display display mode for annotations
border side of map for annotations

void QgsLayoutItemMapGrid::setAnnotationEnabled(const bool enabled)

Sets whether annotations should be shown for the grid.

void QgsLayoutItemMapGrid::setAnnotationExpression(const QString& expression)

Sets the expression used for drawing grid annotations.

This is only used when annotationFormat() is QgsLayoutItemMapGrid::CustomFormat.

void QgsLayoutItemMapGrid::setAnnotationFont(const QFont& font)

Sets the font used for drawing grid annotations.

void QgsLayoutItemMapGrid::setAnnotationFontColor(const QColor& color)

Sets the font color used for drawing grid annotations.

void QgsLayoutItemMapGrid::setAnnotationFormat(const AnnotationFormat format)

Sets the format for drawing grid annotations.

void QgsLayoutItemMapGrid::setAnnotationFrameDistance(const double distance)

Sets the distance between the map frame and annotations.

Units are layout units.

void QgsLayoutItemMapGrid::setAnnotationPosition(AnnotationPosition position, BorderSide side)

Sets the position for the grid annotations on a specified side of the map frame.

void QgsLayoutItemMapGrid::setAnnotationPrecision(const int precision)

Sets the coordinate precision for grid annotations.

The precision indicates the number of decimal places to show when drawing grid annotations.

void QgsLayoutItemMapGrid::setBlendMode(const QPainter::CompositionMode mode)

Sets the blending mode used for drawing the grid.

void QgsLayoutItemMapGrid::setCrossLength(const double length)

Sets the length (in layout units) of the cross segments drawn for the grid.

This is only used for grids with QgsLayoutItemMapGrid::Cross styles.

void QgsLayoutItemMapGrid::setCrs(const QgsCoordinateReferenceSystem& crs)

Sets the crs for the grid.

void QgsLayoutItemMapGrid::setFrameDivisions(DisplayMode divisions, BorderSide side)

Sets what type of grid divisions should be used for frames on a specified side of the map.

void QgsLayoutItemMapGrid::setFrameFillColor1(const QColor& color)

Sets the first fill color used for the grid frame.

void QgsLayoutItemMapGrid::setFrameFillColor2(const QColor& color)

Sets the second fill color used for the grid frame.

void QgsLayoutItemMapGrid::setFrameMargin(const double margin)

Sets the grid frame margin (in layout units).

This property controls distance between the map frame and the grid frame.

void QgsLayoutItemMapGrid::setFramePenColor(const QColor& color)

Sets the color of the stroke drawn in the grid frame.

void QgsLayoutItemMapGrid::setFramePenSize(const double width)

Sets the width of the stroke drawn in the grid frame.

void QgsLayoutItemMapGrid::setFrameSideFlag(QgsLayoutItemMapGrid::FrameSideFlag flag, bool on = true)

Sets whether the grid frame is drawn for a certain side of the map item.

Parameters
flag flag for grid frame side
on set to true to draw grid frame on that side of the map

void QgsLayoutItemMapGrid::setFrameSideFlags(QgsLayoutItemMapGrid::FrameSideFlags flags)

Sets flags for grid frame sides.

Setting these flags controls which sides of the map item the grid frame is drawn on.

void QgsLayoutItemMapGrid::setFrameStyle(const FrameStyle style)

Sets the grid frame style.

void QgsLayoutItemMapGrid::setFrameWidth(const double width)

Sets the grid frame width (in layout units).

This property controls how wide the grid frame is. The size of the line outlines drawn in the frame is controlled through the setFramePenSize method.

void QgsLayoutItemMapGrid::setGridLineColor(const QColor& color)

Sets the color of grid lines.

This is only used for grids with QgsLayoutItemMapGrid::Solid or QgsLayoutItemMapGrid::Cross styles. For more control over grid line appearance, use setLineSymbol instead.

void QgsLayoutItemMapGrid::setGridLineWidth(double width)

Sets the width of grid lines (in layout units).

This is only used for grids with QgsLayoutItemMapGrid::Solid or QgsLayoutItemMapGrid::Cross styles. For more control over grid line appearance, use setLineSymbol instead.

void QgsLayoutItemMapGrid::setIntervalX(double interval)

Sets the interval between grid lines in the x-direction.

The units are controlled through the setUnits method

void QgsLayoutItemMapGrid::setIntervalY(double interval)

Sets the interval between grid lines in the y-direction.

The units are controlled through the setUnits method

void QgsLayoutItemMapGrid::setLineSymbol(QgsLineSymbol* symbol)

Sets the line symbol used for drawing grid lines.

This is only used for grids with QgsLayoutItemMapGrid::Solid or QgsLayoutItemMapGrid::Cross styles. Ownership of symbol is transferred to the grid.

void QgsLayoutItemMapGrid::setMarkerSymbol(QgsMarkerSymbol* symbol)

Sets the marker symbol used for drawing grid points.

This is only used for grids with a QgsLayoutItemMapGrid::Markers style. Ownership of symbol is transferred to the grid.

void QgsLayoutItemMapGrid::setOffsetX(double offset)

Sets the offset for grid lines in the x-direction.

The units are controlled through the setUnits method.

void QgsLayoutItemMapGrid::setOffsetY(double offset)

Sets the offset for grid lines in the y-direction.

The units are controlled through the setUnits method.

void QgsLayoutItemMapGrid::setStyle(GridStyle style)

Sets the grid style, which controls how the grid is drawn over the map's contents.

void QgsLayoutItemMapGrid::setUnits(GridUnit unit)

Sets the unit to use for grid measurements such as the interval and offset for grid lines.

GridStyle QgsLayoutItemMapGrid::style() const

Returns the grid's style, which controls how the grid is drawn over the map's contents.

bool QgsLayoutItemMapGrid::testFrameSideFlag(FrameSideFlag flag) const

Tests whether the grid frame should be drawn on a specified side of the map item.

Parameters
flag flag for grid frame side
Returns true if grid frame should be drawn for that side of the map

GridUnit QgsLayoutItemMapGrid::units() const

Returns the units used for grid measurements such as the interval and offset for grid lines.

bool QgsLayoutItemMapGrid::writeXml(QDomElement& element, QDomDocument& document, const QgsReadWriteContext& context) const override

Stores map item state in a DOM element, where element is the DOM element corresponding to a 'LayoutMap' tag.