createLayer (name, hrService) {
    if (this.current_layer) {
      this.current_layer.deactivate()
    }
    // Check for duplicate name.
    if (
      name === undefined ||
      name === null ||
      name === '' ||
      this.layer_map[name]
    ) {
      name = getNewLayerName(Object.keys(this.layer_map))
    }

    // Crate new layer and add to DOM as last layer
    const layer = new Layer(name, null, this.svgElem_)
    // Like to assume hrService exists, but this is backwards compatible with old version of createLayer.
    if (hrService) {
      hrService.startBatchCommand('Create Layer')
      hrService.insertElement(layer.getGroup())
      hrService.endBatchCommand()
    }

    this.all_layers.push(layer)
    this.layer_map[name] = layer
    this.current_layer = layer
    return layer.getGroup()
  }
Creates a new top-level layer in the drawing with the given name and
makes it the current layer.
@param {string} name - The given name. If the layer name exists, a new name will be generated.
@param {module:history.HistoryRecordingService} hrService - History recording service
@returns {SVGGElement} The SVGGElement of the new layer, which is
    also the current layer of this drawing.