Hi,
I’m trying to use a specific layer to draw shapes by specifying a layer object when creating my root element :
const layerName = "my-layer";
var layer = this._canvas.getLayer(layerName) || this._canvas.createLayer(layerName);
var attrs = {
type: 'root',
layer: layerName
};
var rootElement = this._elementFactory.createRoot(attrs);
this._canvas.setRootElement(rootElement);
The layer is created but the root element still uses a ‘root-3’ layer.
What is this ‘root-3’ layer ? Why does the root element not use the ‘base’ layer ? And how to set a specific layer for a root element ?
Thanks a lot
A plane will be associated with an automatically created layer.
Canvas#setRootElement will set the active root element by finding an existing one (and its associated plane and layer) or creating a new one (and its plane and layer).
Your my-layer will not be chosen as the layer for the new root element.
After Canvas#setRootElement you can use Canvas#getActiveLayer to get the layer that was created for your new root element.