import { linkMaps } from "@gvol-org/geovis-brain-core";
import { ActiveList } from "./ActiveList";
import { Map } from "./Map";
/**
 * @class Map.Linker
 * @since ui.Map
 */
export class Linker extends ActiveList {
  mapboxs: any = [];
   /**
    * @hideconstructor
   * 地图联动
   * @param { object[]} [maps] 地图列表
   * @return ui.Map.Linker
   */
  constructor(maps?: object[]) {
    super(maps);
    if (!(this instanceof Linker)) {
      return new Linker(maps);
    }
    if (maps) {
      //兼容print uiMap
      setTimeout(() => {
        for (let index = 0; index < maps.length; index++) {
          const element = maps[index];
          if (element instanceof Map) {
            if (element.map) {
              this.mapboxs.push(element.map);
            }
          }
        }
        linkMaps(this.mapboxs);
      }, 0);
     
    }
  }
}