Class: QgsLayoutItemMapGrid

class qgis.core.QgsLayoutItemMapGrid(name: str, map: QgsLayoutItemMap)

Bases: QgsLayoutItemMapItem

Constructor for QgsLayoutItemMapGrid.

Parameters

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

Methods

accept

param visitor

annotationDirection

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

annotationDisplay

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

annotationEnabled

Returns whether annotations are shown for the grid.

annotationExpression

Returns the expression used for drawing grid annotations.

annotationFont

Returns the font used for drawing grid annotations.

annotationFontColor

Returns the font color used for drawing grid annotations.

annotationFormat

Returns the format for drawing grid annotations.

annotationFrameDistance

Returns the distance between the map frame and annotations.

annotationPosition

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

annotationPrecision

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

blendMode

Retrieves the blending mode used for drawing the grid.

calculateMaxExtension

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

childEvent

connectNotify

createExpressionContext

rtype

QgsExpressionContext

crossLength

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

crs

Retrieves the CRS for the grid.

customEvent

disconnectNotify

draw

param painter

frameDivisions

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

frameFillColor1

Retrieves the first fill color for the grid frame.

frameFillColor2

Retrieves the second fill color for the grid frame.

frameMargin

Sets the grid frame Margin (in layout units).

framePenColor

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

framePenSize

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

frameSideFlags

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

frameStyle

Returns the grid frame style.

frameWidth

Gets the grid frame width in layout units.

intervalX

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

intervalY

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

isSignalConnected

lineSymbol

Returns the line symbol used for drawing grid lines.

markerSymbol

Returns the marker symbol used for drawing grid points.

maxExtension

Calculates the maximum distance the grid extends beyond the QgsLayoutItemMap’s item rect (in layout units).

maximumIntervalWidth

Returns the maximum width (in millimeters) for grid segments.

minimumIntervalWidth

Returns the minimum width (in millimeters) for grid segments.

offsetX

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

offsetY

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

readObjectPropertiesFromElement

readXml

param itemElem

receivers

refresh

sender

senderSignalIndex

setAnnotationDirection

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

setAnnotationDisplay

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.

setAnnotationEnabled

Sets whether annotations should be shown for the grid.

setAnnotationExpression

Sets the expression used for drawing grid annotations.

setAnnotationFont

Sets the font used for drawing grid annotations.

setAnnotationFontColor

Sets the font color used for drawing grid annotations.

setAnnotationFormat

Sets the format for drawing grid annotations.

setAnnotationFrameDistance

Sets the distance between the map frame and annotations.

setAnnotationPosition

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

setAnnotationPrecision

Sets the coordinate precision for grid annotations.

setBlendMode

Sets the blending mode used for drawing the grid.

setCrossLength

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

setCrs

Sets the crs for the grid.

setEnabled

param enabled

setFrameDivisions

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

setFrameFillColor1

Sets the first fill color used for the grid frame.

setFrameFillColor2

Sets the second fill color used for the grid frame.

setFrameMargin

Sets the grid frame margin (in layout units).

setFramePenColor

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

setFramePenSize

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

setFrameSideFlag

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

setFrameSideFlags

Sets flags for grid frame sides.

setFrameStyle

Sets the grid frame style.

setFrameWidth

Sets the grid frame width (in layout units).

setGridLineColor

Sets the color of grid lines.

setGridLineWidth

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

setIntervalX

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

setIntervalY

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

setLineSymbol

Sets the line symbol used for drawing grid lines.

setMarkerSymbol

Sets the marker symbol used for drawing grid points.

setMaximumIntervalWidth

Sets the maximum width (in millimeters) for grid segments.

setMinimumIntervalWidth

Sets the minimum width (in millimeters) for grid segments.

setOffsetX

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

setOffsetY

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

setStyle

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

setUnits

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

style

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

testFrameSideFlag

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

timerEvent

units

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

usesAdvancedEffects

rtype

bool

writeObjectPropertiesToElement

writeXml

param elem

Attributes

Bottom

BoundaryDirection

CM

Cross

CustomFormat

Decimal

DecimalWithSuffix

DegreeMinute

DegreeMinuteNoSuffix

DegreeMinutePadded

DegreeMinuteSecond

DegreeMinuteSecondNoSuffix

DegreeMinuteSecondPadded

DynamicPageSizeBased

ExteriorTicks

FrameAnnotationsOnly

FrameBottom

FrameLeft

FrameRight

FrameTop

HideAll

Horizontal

InsideMapFrame

InteriorExteriorTicks

InteriorTicks

Latitude

LatitudeOnly

Left

LineBorder

LineBorderNautical

Longitude

LongitudeOnly

MM

MapUnit

Markers

NoFrame

OutsideMapFrame

Right

ShowAll

Solid

Top

Vertical

VerticalDescending

Zebra

ZebraNautical

class AnnotationCoordinate

Bases: int

class AnnotationDirection

Bases: int

class AnnotationFormat

Bases: int

class AnnotationPosition

Bases: int

class BorderSide

Bases: int

Bottom = 2
BoundaryDirection = 3
CM = 2
Cross = 1
CustomFormat = 8
Decimal = 0
DecimalWithSuffix = 3
DegreeMinute = 1
DegreeMinuteNoSuffix = 4
DegreeMinutePadded = 5
DegreeMinuteSecond = 2
DegreeMinuteSecondNoSuffix = 6
DegreeMinuteSecondPadded = 7
class DisplayMode

Bases: int

DynamicPageSizeBased = 3
ExteriorTicks = 3
FrameAnnotationsOnly = 3
FrameBottom = 8
FrameLeft = 1
FrameRight = 2
class FrameSideFlag

Bases: int

class FrameSideFlags

Bases: sip.wrapper

QgsLayoutItemMapGrid.FrameSideFlags(Union[QgsLayoutItemMapGrid.FrameSideFlags, QgsLayoutItemMapGrid.FrameSideFlag]) QgsLayoutItemMapGrid.FrameSideFlags(QgsLayoutItemMapGrid.FrameSideFlags)

class FrameStyle

Bases: int

FrameTop = 4
class GridStyle

Bases: int

class GridUnit

Bases: int

HideAll = 3
Horizontal = 0
InsideMapFrame = 0
InteriorExteriorTicks = 4
InteriorTicks = 2
Latitude = 1
LatitudeOnly = 1
Left = 0
LineBorder = 5
LineBorderNautical = 6
Longitude = 0
LongitudeOnly = 2
MM = 1
MapUnit = 0
Markers = 2
NoFrame = 0
OutsideMapFrame = 1
Right = 1
ShowAll = 0
Solid = 0
Top = 3
Vertical = 1
VerticalDescending = 2
Zebra = 1
ZebraNautical = 7
accept(self, visitor: QgsStyleEntityVisitorInterface) → bool
Parameters

visitor (QgsStyleEntityVisitorInterface) –

Return type

bool

annotationDirection(self, border: QgsLayoutItemMapGrid.BorderSide) → QgsLayoutItemMapGrid.AnnotationDirection

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

Parameters

border (QgsLayoutItemMapGrid.BorderSide) –

Return type

QgsLayoutItemMapGrid.AnnotationDirection

annotationDisplay(self, border: QgsLayoutItemMapGrid.BorderSide) → QgsLayoutItemMapGrid.DisplayMode

Returns the display mode for the grid annotations on a specified side of the map frame. This property also specifies whether annotations have been disabled from a side of the map frame.

Parameters

border (QgsLayoutItemMapGrid.BorderSide) – side of map for annotations

Return type

QgsLayoutItemMapGrid.DisplayMode

Returns

display mode for grid annotations

annotationEnabled(self) → bool

Returns whether annotations are shown for the grid.

Return type

bool

annotationExpression(self) → str

Returns the expression used for drawing grid annotations. This is only used when annotationFormat() is QgsLayoutItemMapGrid.CustomFormat.

Return type

str