Class: QgsMarkerSymbol

class qgis.core.QgsMarkerSymbol(layers: object = QgsSymbolLayerList())

Bases: qgis._core.QgsSymbol

Constructor for QgsMarkerSymbol, with the specified list of initial symbol layers.

Ownership of the layers are transferred to the symbol.

A marker symbol type, for rendering Point and MultiPoint geometries.

Enums

Methods

angle Returns the marker angle for the whole symbol.
bounds Returns the approximate bounding box of the marker symbol, which includes the bounding box of all symbol layers for the symbol.
clone
cloneLayers
createSimple Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
dataDefinedAngle Returns data defined angle for whole symbol (including all symbol layers).
dataDefinedSize Returns data defined size for whole symbol (including all symbol layers).
renderPoint
renderUsingLayer
renderVertexMarker
scaleMethod
setAngle Sets the angle for the whole symbol.
setDataDefinedAngle Set data defined angle for whole symbol (including all symbol layers).
setDataDefinedSize Set data defined size for whole symbol (including all symbol layers).
setLineAngle Sets the line angle modification for the symbol’s angle.
setScaleMethod
setSize Sets the size for the whole symbol.
setSizeMapUnitScale Sets the size map unit scale for the whole symbol (including all symbol layers).
setSizeUnit Sets the size units for the whole symbol (including all symbol layers).
size Returns the estimated size for the whole symbol, which is the maximum size of all marker symbol layers in the symbol.
sizeMapUnitScale Returns the size map unit scale for the whole symbol.
sizeUnit Returns the size units for the whole symbol (including all symbol layers).

Signals

Attributes

angle(self) → float

Returns the marker angle for the whole symbol. Note that for symbols with multiple symbol layers, this will correspond just to the angle of the first symbol layer.

See also

setAngle()

New in version 2.16.

bounds(self, point: Union[QPointF, QPoint], context: QgsRenderContext, feature: QgsFeature = QgsFeature()) → QRectF

Returns the approximate bounding box of the marker symbol, which includes the bounding box of all symbol layers for the symbol. It is recommended to use this method only between startRender() and stopRender() calls, or data defined rotation and offset will not be correctly calculated.

Parameters:
  • point – location of rendered point in painter units
  • context – render context
  • feature – feature being rendered at point (optional). If not specified, the bounds calculation will not include data defined parameters such as offset and rotation
Returns:

approximate symbol bounds, in painter units

New in version 2.14.

clone(self) → QgsMarkerSymbol
cloneLayers()
createSimple(properties: Dict[str, str]) → QgsMarkerSymbol

Create a marker symbol with one symbol layer: SimpleMarker with specified properties. This is a convenience method for easier creation of marker symbols.

dataDefinedAngle(self) → QgsProperty

Returns data defined angle for whole symbol (including all symbol layers).

Returns:data defined angle, or invalid property if angle is not set at the marker level.

New in version 3.0.

dataDefinedSize(self) → QgsProperty

Returns data defined size for whole symbol (including all symbol layers).

Returns:data defined size, or invalid property if size is not set at the marker level.

New in version 3.0.

renderPoint(self, point: Union[QPointF, QPoint], f: QgsFeature, context: QgsRenderContext, layer: int = -1, selected: bool = False)
renderUsingLayer()
renderVertexMarker()
scaleMethod(self) → QgsSymbol.ScaleMethod
setAngle(self, symbolAngle: float)

Sets the angle for the whole symbol. Individual symbol layer sizes will be rotated to maintain their current relative angle to the whole symbol angle.

Parameters:symbolAngle – new symbol angle

See also

angle()

setDataDefinedAngle(self, property: QgsProperty)

Set data defined angle for whole symbol (including all symbol layers).

New in version 3.0.

setDataDefinedSize(self, property: QgsProperty)

Set data defined size for whole symbol (including all symbol layers).

New in version 3.0.

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 – Angle in degrees, valid values are between 0 and 360

New in version 2.9.

setScaleMethod(self, scaleMethod: QgsSymbol.ScaleMethod)
setSize(self, size: float)

Sets the size for the whole symbol. Individual symbol layer sizes will be scaled to maintain their current relative size to the whole symbol size.

Parameters:size – new symbol size

See also

size()

See also

setSizeUnit()

setSizeMapUnitScale(self, scale: QgsMapUnitScale)

Sets the size map unit scale for the whole symbol (including all symbol layers).

Parameters:scale – map unit scale

See also

setSizeUnit()

See also

setSize()

New in version 2.16.

setSizeUnit(self, unit: QgsUnitTypes.RenderUnit)

Sets the size units for the whole symbol (including all symbol layers).

Parameters:unit – size units

See also

sizeUnit()

See also

setSize()

New in version 2.16.

size(self) → float

Returns the estimated size for the whole symbol, which is the maximum size of all marker symbol layers in the symbol.

Warning

This returned value is inaccurate if the symbol consists of multiple symbol layers with different size units. Use the overload accepting a QgsRenderContext argument instead for accurate sizes in this case.

See also

setSize()

See also

sizeUnit()

size(self, context: QgsRenderContext) -> float Returns the symbol size, in painter units. This is the maximum size of all marker symbol layers in the symbol.

This method returns an accurate size by calculating the actual rendered size of each symbol layer using the provided render context.

See also

setSize()

See also

sizeUnit()

New in version 3.4.5.

sizeMapUnitScale(self) → QgsMapUnitScale

Returns the size map unit scale for the whole symbol. Note that for symbols with multiple symbol layers, this will correspond just to the map unit scale for the first symbol layer.

See also

sizeUnit()

See also

size()

New in version 2.16.

sizeUnit(self) → QgsUnitTypes.RenderUnit

Returns the size units for the whole symbol (including all symbol layers).

Returns:size units, or mixed units if symbol layers have different units

See also

setSizeUnit()

See also

size()

New in version 2.16.