Combining symbol layers
By combining symbol layers, you can achieve a range of complex visual effects. For example, you can combine an instance of QgsSimpleMarkerSymbolLayerV2
with an instance of QgsVectorFieldSymbolLayer
to display a point geometry using two symbols at once:
One of the main uses of symbol layers is to draw different LineString or PolyLine symbols to represent different types of roads. For example, you can draw a complex road symbol by combining multiple symbol layers, like this:
This effect is achieved by using three separate symbol layers:
Here is the Python code used to generate the preceding map symbol:
symbol =QgsLineSymbolV2.createSimple({}) symbol.deleteSymbolLayer(0) # Remove default symbol layer. symbol_layer = QgsSimpleLineSymbolLayerV2() symbol_layer.setWidth(4) symbol_layer.setColor(QColor("light gray")) symbol_layer.setPenCapStyle(Qt.FlatCap) symbol.appendSymbolLayer(symbol_layer) symbol_layer = QgsSimpleLineSymbolLayerV2() symbol_layer.setColor(QColor("black...