class TileLayerWrapper {
  self: L.TileLayer;
  name: string;
  visible: boolean = false;
  
  constructor(name: string, self: L.TileLayer) {
    this.self = self;
    this.name = name;
  }
  
  static constructLayer(name: string, self: L.TileLayer): TileLayerWrapper {
    const wrapper = new TileLayerWrapper(name, self);
    TileLayerWrapper.layers.push(wrapper);
    return wrapper;
  }
  
  static getActiveLayer(): string | null {
    for (const l of TileLayerWrapper.layers) {
      if (l.visible == true) {
        return l.name;
      }
    }
    return null;
  }
  static layers: TileLayerWrapper[] = new Array<TileLayerWrapper>();
  static enableOnly(self: string, map: L.Map): void {
    for (const l of TileLayerWrapper.layers) {
      if (l.visible) {
        l.self.removeFrom(map);
        l.visible = false;
      }
      if (l.name == self) {
        l.self.addTo(map);
        l.visible = true;
      }
    }
  }
}