Class: QgsMarkerSymbolLayer

class qgis.core.QgsMarkerSymbolLayer

Bases: QgsSymbolLayer

Abstract base class for marker symbol layers.

QgsMarkerSymbolLayer(locked: bool = False) Constructor for QgsMarkerSymbolLayer.

Parameters:

locked

set to True to lock symbol color

Methods

angle

Returns the rotation angle for the marker, in degrees clockwise from north.

bounds

Returns the approximate bounding box of the marker symbol layer, taking into account any data defined overrides and offsets which are set for the marker layer.

copyDataDefinedProperties

Copies all data defined properties of this layer to another symbol layer.

copyPaintEffect

Copies paint effect of this layer to another symbol layer

drawPreviewIcon

param context:

dxfAngle

param context:

dxfSize

param e:

horizontalAnchorPoint

Returns the horizontal anchor point for positioning the symbol.

installMasks

When rendering, install masks on context painter if recursive is True masks are installed recursively for all children symbol layers

mapUnitScale

rtype:

QgsMapUnitScale

markerOffset

Calculates the required marker offset, including both the symbol offset and any displacement required to align with the marker's anchor point.

markerOffset2

markerOffsetWithWidthAndHeight

Calculates the required marker offset, including both the symbol offset and any displacement required to align with the marker's anchor point.

offset

Returns the marker's offset, which is the horizontal and vertical displacement which the rendered marker will have from the original feature's geometry.

offsetMapUnitScale

Returns the map unit scale for the symbol's offset.

offsetUnit

Returns the units for the symbol's offset.

outputUnit

rtype:

Qgis.RenderUnit

removeMasks

When rendering, remove previously installed masks from context painter if recursive is True masks are removed recursively for all children symbol layers

renderPoint

Renders a marker at the specified point.

restoreOldDataDefinedProperties

Restores older data defined properties from string map.

scaleMethod

Returns the method to use for scaling the marker's size.

setAngle

Sets the rotation angle for the marker.

setHorizontalAnchorPoint

Sets the horizontal anchor point for positioning the symbol.

setLineAngle

Sets the line angle modification for the symbol's angle.

setMapUnitScale

param scale:

setOffset

Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker should have from the original feature's geometry.

setOffsetMapUnitScale

Sets the map unit scale for the symbol's offset.

setOffsetUnit

Sets the units for the symbol's offset.

setOutputUnit

param unit:

setScaleMethod

Sets the method to use for scaling the marker's size.

setSize

Sets the symbol size.

setSizeMapUnitScale

Sets the map unit scale for the symbol's size.

setSizeUnit

Sets the units for the symbol's size.

setVerticalAnchorPoint

Sets the vertical anchor point for positioning the symbol.

shouldRenderUsingSelectionColor

Returns True if the symbol layer should be rendered using the selection color from the render context.

size

Returns the symbol size.

sizeMapUnitScale

Returns the map unit scale for the symbol's size.

sizeUnit

Returns the units for the symbol's size.

startRender

QgsMarkerSymbolLayer cannot be copied

stopRender

param context:

toSld

param doc:

verticalAnchorPoint

Returns the vertical anchor point for positioning the symbol.

writeSldMarker

Writes the symbol layer definition as a SLD XML element.

Attributes

Bottom

HCenter

Left

Right

Top

VCenter

Bottom = 2
HCenter = 1
class HorizontalAnchorPoint

Bases: int

Left = 0
Right = 2
Top = 0
VCenter = 1
class VerticalAnchorPoint

Bases: int

angle(self) float

Returns the rotation angle for the marker, in degrees clockwise from north.

See also

setAngle()

Return type:

float

bounds(self, point: QPointF | QPoint, context: QgsSymbolRenderContext) QRectF

Returns the approximate bounding box of the marker symbol layer, taking into account any data defined overrides and offsets which are set for the marker layer.

Return type:

QRectF

Returns:

approximate symbol bounds, in painter units

Parameters:
copyDataDefinedProperties(self, destLayer: QgsSymbolLayer | None)

Copies all data defined properties of this layer to another symbol layer.

Parameters:

destLayer – destination layer

copyPaintEffect(self, destLayer: QgsSymbolLayer | None)

Copies paint effect of this layer to another symbol layer

Parameters:

destLayer – destination layer

drawPreviewIcon(self, context: QgsSymbolRenderContext, size: QSize)
Parameters:
dxfAngle(self, context: QgsSymbolRenderContext) float
Parameters:

context (QgsSymbolRenderContext)

Return type:

float

dxfSize(self, e: QgsDxfExport, context: QgsSymbolRenderContext) float
Parameters:
Return type:

float

horizontalAnchorPoint(self) QgsMarkerSymbolLayer.HorizontalAnchorPoint

Returns the horizontal anchor point for positioning the symbol. The symbol will be drawn so that the horizontal anchor point is aligned with the marker’s desired location.

Return type:

QgsMarkerSymbolLayer.HorizontalAnchorPoint

installMasks(self, context: QgsRenderContext, recursive: bool)

When rendering, install masks on context painter if recursive is True masks are installed recursively for all children symbol layers

See also

prepareMasks()

See also

removeMasks()

Added in version 3.30.

mapUnitScale(self) QgsMapUnitScale
Return type:

QgsMapUnitScale

markerOffset(self, context: QgsSymbolRenderContext)

Calculates the required marker offset, including both the symbol offset and any displacement required to align with the marker’s anchor point.

Parameters:
  • context (QgsSymbolRenderContext) -> (float) – symbol render context

  • offsetX – will be set to required horizontal offset (in painter units)

  • offsetY – will be set to required vertical offset (in painter units)

markerOffset2(self, context: QgsSymbolRenderContext, width: float, height: float, widthUnit: Qgis.RenderUnit, heightUnit: Qgis.RenderUnit, widthMapUnitScale: QgsMapUnitScale, heightMapUnitScale: QgsMapUnitScale)

Note

available in Python bindings as markerOffset2

Parameters:
markerOffsetWithWidthAndHeight(self, context: QgsSymbolRenderContext, width: float, height: float)

Calculates the required marker offset, including both the symbol offset and any displacement required to align with the marker’s anchor point.

Parameters:
  • context (QgsSymbolRenderContext) – symbol render context

  • width (float) – marker width

  • height (float) -> (float) – marker height

  • offsetX – will be set to required horizontal offset (in painter units)

  • offsetY – will be set to required vertical offset (in painter units)

Note

available in Python as markerOffsetWithWidthAndHeight

offset(self) QPointF

Returns the marker’s offset, which is the horizontal and vertical displacement which the rendered marker will have from the original feature’s geometry. Units are specified by offsetUnit().

See also

setOffset()

See also

offsetUnit()

Return type:

QPointF

offsetMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the symbol’s offset.

See also

offset()

See also

offsetUnit()

Return type:

QgsMapUnitScale

offsetUnit(self) Qgis.RenderUnit

Returns the units for the symbol’s offset.

See also

setOffsetUnit()

See also

offset()

Return type:

Qgis.RenderUnit

outputUnit(self) Qgis.RenderUnit
Return type:

Qgis.RenderUnit

removeMasks(self, context: QgsRenderContext, recursive: bool)

When rendering, remove previously installed masks from context painter if recursive is True masks are removed recursively for all children symbol layers

See also

prepareMasks()

See also

installMasks()

Added in version 3.30.

renderPoint(self, point: QPointF | QPoint, context: QgsSymbolRenderContext)

Renders a marker at the specified point. Derived classes must implement this to handle drawing the point.

Parameters:
  • point (Union[QPointF) – position at which to render point, in painter units

  • context (QgsSymbolRenderContext) – symbol render context

restoreOldDataDefinedProperties(self, stringMap: Dict[str, Any])

Restores older data defined properties from string map.

scaleMethod(self) Qgis.ScaleMethod

Returns the method to use for scaling the marker’s size.

See also

setScaleMethod()

Return type:

Qgis.ScaleMethod

setAngle(self, angle: float)

Sets the rotation angle for the marker.

Parameters:

angle (float) – angle in degrees clockwise from north.

See also

angle()

See also

setLineAngle()

setHorizontalAnchorPoint(self, h: QgsMarkerSymbolLayer.HorizontalAnchorPoint)

Sets the horizontal anchor point for positioning the symbol.

Parameters:

h (QgsMarkerSymbolLayer.HorizontalAnchorPoint) – anchor point. Symbol will be drawn so that the horizontal anchor point is aligned with the marker’s desired location.

setLineAngle(self, lineAngle: float)

Sets the line angle modification for the symbol’s angle. This angle is added to the marker’s rotation and data defined rotation before rendering the symbol, and is usually used for orienting symbols to match a line’s angle.

Parameters:

lineAngle (float) – Angle in degrees clockwise from north, valid values are between 0 and 360

See also

setAngle()

See also

angle()

setMapUnitScale(self, scale: QgsMapUnitScale)
Parameters:

scale (QgsMapUnitScale)

setOffset(self, offset: QPointF | QPoint)

Sets the marker’s offset, which is the horizontal and vertical displacement which the rendered marker should have from the original feature’s geometry.

Parameters:

offset (Union[QPointF) – marker offset. Units are specified by offsetUnit()

See also

offset()

See also

setOffsetUnit()

setOffsetMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale for the symbol’s offset.

Parameters:

scale (QgsMapUnitScale) – offset map unit scale

See also

setOffset()

See also

setOffsetUnit()

setOffsetUnit(self, unit: Qgis.RenderUnit)

Sets the units for the symbol’s offset.

Parameters:

unit (Qgis.RenderUnit) – offset units

See also

offsetUnit()

See also

setOffset()

setOutputUnit(self, unit: Qgis.RenderUnit)
Parameters:

unit (Qgis.RenderUnit)

setScaleMethod(self, scaleMethod: Qgis.ScaleMethod)

Sets the method to use for scaling the marker’s size.

Parameters:

scaleMethod (Qgis.ScaleMethod) – scale method

See also

scaleMethod()

setSize(self, size: float)

Sets the symbol size.

Parameters:

size (float) – symbol size. Units are specified by sizeUnit().

See also

size()

See also

setSizeUnit()

setSizeMapUnitScale(self, scale: QgsMapUnitScale)

Sets the map unit scale for the symbol’s size.

Parameters:

scale (QgsMapUnitScale) – size map unit scale

See also

setSize()

See also

setSizeUnit()

setSizeUnit(self, unit: Qgis.RenderUnit)

Sets the units for the symbol’s size.

Parameters:

unit (Qgis.RenderUnit) – size units

See also

sizeUnit()

See also

setSize()

setVerticalAnchorPoint(self, v: QgsMarkerSymbolLayer.VerticalAnchorPoint)

Sets the vertical anchor point for positioning the symbol.

Parameters:

v (QgsMarkerSymbolLayer.VerticalAnchorPoint) – anchor point. Symbol will be drawn so that the vertical anchor point is aligned with the marker’s desired location.

shouldRenderUsingSelectionColor(self, context: QgsSymbolRenderContext) bool

Returns True if the symbol layer should be rendered using the selection color from the render context.

Added in version 3.34.

size(self) float

Returns the symbol size. Units are specified by sizeUnit().

See also

setSize()

See also

sizeUnit()

Return type:

float

sizeMapUnitScale(self) QgsMapUnitScale

Returns the map unit scale for the symbol’s size.

See also

size()

See also

sizeUnit()

Return type:

QgsMapUnitScale

sizeUnit(self) Qgis.RenderUnit

Returns the units for the symbol’s size.

See also

setSizeUnit()

See also

size()

Return type:

Qgis.RenderUnit

startRender(self, context: QgsSymbolRenderContext)

QgsMarkerSymbolLayer cannot be copied

Parameters:

context (QgsSymbolRenderContext)

stopRender(self, context: QgsSymbolRenderContext)
Parameters:

context (QgsSymbolRenderContext)

toSld(self, doc: QDomDocument, element: QDomElement, props: Dict[str, Any])
Parameters:
  • doc (QDomDocument)

  • element (QDomElement)

  • props (Dict[str)

verticalAnchorPoint(self) QgsMarkerSymbolLayer.VerticalAnchorPoint

Returns the vertical anchor point for positioning the symbol. The symbol will be drawn so that the vertical anchor point is aligned with the marker’s desired location.

Return type:

QgsMarkerSymbolLayer.VerticalAnchorPoint

writeSldMarker(self, doc: QDomDocument, element: QDomElement, props: Dict[str, Any])

Writes the symbol layer definition as a SLD XML element.

Parameters:
  • doc (QDomDocument) – XML document

  • element (QDomElement) – parent XML element

  • props (Dict[str) – symbol layer definition (see properties())