    import { Zondy, Evented, Collection, LayerEvent } from '../../base'
    import { LayerType, MapEventType } from '../../base/enum'
    import { Layer, SubLayer } from '../layer/baseLayer'
    import { cloneObject, defaultValue } from '../../util'
    import { IGSMapImageLayer } from '../layer'

    /**
     * 图层管理容器，和地图引擎无关，通过此对象而不是地图引擎来对图层进行管理
     * <br>[ES5引入方式]：<br/>
     * Zondy.Map() <br/>
     * [ES6引入方式]：<br/>
     * import { Map } from "@mapgis/webclient-common" <br/>
     * @class Map
     * @moduleEX LayerManagerModule
     * @extends Evented
     * @fires Map#添加图层事件
     * @fires Map#添加多个图层事件
     * @fires Map#删除图层事件
     * @fires Map#移除多个图层事件
     * @fires Map#移除所有图层事件
     * @param {Object} options 构造参数
     *
     * @summary <h5>支持如下方法：</h5>
     * <a href='#add'>[1、添加图层对象]</a><br/>
     * <a href='#addMany'>[2、添加多个图层]</a><br/>
     * <a href='#findLayerById'>[3、根据id查询图层]</a><br/>
     * <a href='#remove'>[4、删除指定图层]</a><br/>
     * <a href='#removeMany'>[5、移除多个图层]</a><br/>
     * <a href='#removeAll'>[6、删除所有图层]</a><br/>
     * <a href='#reorder'>[7、调整图层顺序]</a><br/>
     * <a href='#destroy'>[8、销毁Map对象]</a><br/>
     * <a href='#fromJSON'>[9、通过json对象构造并返回一个新的Map对象]</a><br/>
     * <a href='#toJSON'>[10、转换为json对象]</a><br/>
     * <a href='#clone'>[11、克隆并返回一个新的Map对象]</a><br/>
     *
     * @example
     * // ES5引入方式
     * const { Map } = Zondy
     * // ES6引入方式
     * import { Map } from "@mapgis/webclient-common"
     * //创建Map对象
     * let map = new Map();
     */

    /**
     * 添加图层事件
     * @event Map#添加图层事件
     * @property {Object} event 事件对象
     * @property {String} [event.type = 'layer-add'] 添加图层事件
     * @property {Layer} [event.layer = null] 被添加的图层对象
     * @property {View} [event.view = null] 地图视图对象
     * @property {Map} [event.sourceTarget = null] 事件发起对象
     * @property {View} [event.target = null] 事件接收对象
     * @example <caption><h5>添加图层事件</h5></caption>
     * map.on('layer-add', function (event) {
     *   // 添加图层事件
     *   console.log("添加图层事件:", event)
     * });
     */

    /**
     * 添加多个图层事件
     * @event Map#添加多个图层事件
     * @property {Object} event 事件对象
     * @property {String} [event.type = 'layer-add-many'] 添加多个图层事件
     * @property {Array<Layer>} [event.layers = []] 被添加的所有图层对象数组
     * @property {View} [event.view = null] 地图视图对象
     * @property {Map} [event.sourceTarget = null] 事件发起对象
     * @property {View} [event.target = null] 事件接收对象
     * @example <caption><h5>添加多个图层事件</h5></caption>
     * map.on('layer-add-many', function (event) {
     *   // 添加多个图层事件
     *   console.log("添加图层事件:", event)
     * });
     */

    /**
     * 删除图层事件
     * @event Map#删除图层事件
     * @property {Object} event 事件对象
     * @property {String} [event.type = 'layer-remove'] 删除图层事件
     * @property {Layer} [event.layer = null] 被删除的图层对象
     * @property {View} [event.view = null] 地图视图对象
     * @property {Map} [event.sourceTarget = null] 事件发起对象
     * @property {View} [event.target = null] 事件接收对象
     * @example <caption><h5>删除图层事件</h5></caption>
     * map.on('layer-remove', function (event) {
     *   // 删除图层事件
     *   console.log("删除图层事件:", event)
     * });
     */

    /**
     * 移除多个图层事件
     * @event Map#移除多个图层事件
     * @property {Object} event 事件对象
     * @property {String} [event.type = 'layer-remove-many'] 移除多个图层事件
     * @property {Array<Layer>} [event.layers = []] 被删除的所有图层对象数组
     * @property {View} [event.view = null] 地图视图对象
     * @property {Map} [event.sourceTarget = null] 事件发起对象
     * @property {View} [event.target = null] 事件接收对象
     * @example <caption><h5>移除多个图层事件</h5></caption>
     * map.on('layer-remove-many', function (event) {
     *   // 移除多个图层事件
     *   console.log("移除多个图层事件:", event)
     * });
     */

    /**
     * 移除所有图层事件
     * @event Map#移除所有图层事件
     * @property {Object} event 事件对象
     * @property {String} [event.type = 'layer-remove-all'] 移除所有图层事件
     * @property {View} [event.view = null] 地图视图对象
     * @property {Map} [event.sourceTarget = null] 事件发起对象
     * @property {View} [event.target = null] 事件接收对象
     * @example <caption><h5>移除所有图层事件</h5></caption>
     * map.on('layer-remove-all', function (event) {
     *   // 移除所有图层事件
     *   console.log("移除所有图层事件:", event)
     * });
     */
    class Map extends Evented {
      constructor() {
        super()
        /**
         * 图层管理容器中包含的子图层
         * @member {Collection} Map.prototype.layers
         */
        this.layers = new Collection()
        /**
         * 图层管理容器中所有的子图层，包括子图层的子图层，并穷举所有子图层
         * @member {Collection} Map.prototype.allLayers
         */
        this.allLayers = new Collection()
        // 是否绑定Cesium
        this._initCesiumView = false
        // 是否绑定Leaflet
        this._initLeafletView = false
        // 是否删除全部图层
        this._isRemoveAll = false
        // 是否删除多个图层
        this._isRemoveMany = false
      }

      /**
       * 通过json对象构造并返回一个新的Map对象<a id='fromJSON'></a>
       * @param {Object} json json数据
       * @return {Map} 一个新的Map对象
       * */
      static fromJSON(json) {
        json = defaultValue(json, {})
        const layers = defaultValue(json.layers, [])

        const map = new Map()
        for (let i = 0; i < layers.items.length; i++) {
          const _layer = new IGSMapImageLayer(layers.items[i])
          map.add(_layer)
        }

        return map
      }

      /**
       * 转换为json对象<a id='toJSON'></a>
       * @return {Object} 导出的json对象
       */
      toJSON() {
        const json = cloneObject(this)
        // 设置导出配置
        // 导出时间
        json['exportTime'] = new Date().toISOString()

        return json
      }

      /**
       * 克隆并返回一个新的Map对象<a id='clone'></a>
       * @return {Map} 一个新的Map对象
       */
      clone() {
        return cloneObject(this)
      }

      /**
       * 添加图层对象<a id='add'></a>
       * @param {Object} layer 要添加的图层对象
       * @example
       * //添加图层
       * map.add(layer);
       */
      add(layer) {
        if (layer) {
          if (this.findLayerById(layer.id)) {
            throw new Error(`id为'${layer.id}'的图层重复添加，请检查传入图层的id`)
          }
          if (!this._initCesiumView) {
            // 寻找要提供坐标系的图层
            // 当map对象已经绑定Leaflet的MapView且第一次添加图层
            if (this.layers.items.length === 0 && this._initLeafletView) {
              // 确保不是graphics图层
              if (!(layer.type === LayerType.graphics)) {
                layer._isSRLayer = true
              } else {
                throw new Error('GraphicsLayer无法作为底图进行加载！')
              }
            }
            // map对象没有绑定到leaflet的MapView上
            else if (!this._initLeafletView) {
              const layers = this.layers.all()
              // 先找瓦片类型图层的参考系作为底图参考系
              let setSRLayer = false
              for (let i = 0; i < layers.length; i++) {
                if (
                  layers[i].type === LayerType.igsTile ||
                  layers[i].type === LayerType.wmts ||
                  layers[i].type === LayerType.igsVectorTile
                ) {
                  layers[i]._isSRLayer = true
                  setSRLayer = true
                  break
                }
              }
              // 没有则找矢量类型的图层作为参考系
              if (!setSRLayer) {
                for (let i = 0; i < layers.length; i++) {
                  if (
                    layers[i].type === LayerType.igsMapImage ||
                    layers[i].type === LayerType.wms ||
                    layers[i].type === LayerType.igsFeature ||
                    layers[i].type === LayerType.wfs ||
                    layers[i].type === LayerType.geojson ||
                    layers[i].type === LayerType.arcgisMapImage
                  ) {
                    layers[i]._isSRLayer = true
                    setSRLayer = true
                    break
                  }
                }
              }
              // 都没有则找当前添加的图层的坐标系
              if (!setSRLayer) {
                // 确保不是graphics图层
                if (!(layer.type === LayerType.graphics)) {
                  layer._isSRLayer = true
                  setSRLayer = true
                } else {
                  throw new Error('GraphicsLayer无法作为底图进行加载！')
                }
              }
              // 没有找到坐标系
              if (!setSRLayer) {
                throw new Error('没有找到合适的坐标系初始化地图！')
              }
            }
          }
          this._setLayerIndex(layer)
          layer.setMap(this)
          this.layers.add(layer)
          this.dispatchEvent(MapEventType.layerAdd, {
            type: MapEventType.layerAdd,
            target: this,
            layer
          })
        }
      }

      _getSRLayer() {
        const layers = this.layers.all()
        let layer = undefined

        for (let i = 0; i < layers.length; i++) {
          if (layers[i]._isSRLayer) {
            layer = layers[i]
            break
          }
        }

        return layer
      }

      /**
       * 销毁Map对象<a id='destroy'></a>
       * @example
       * map.destroy()
       */
      destroy() {
        const layers = this.layers.all()
        for (let i = 0; i < layers.length; i++) {
          this.remove(layers[i])
        }
        this.layers = undefined
      }

      /**
       * 根据id查询图层<a id='findLayerById'></a>
       * @param {String} id 图层id
       * @return Object 找到的图层
       * @example
       * //根据id查询图层
       * map.findLayerById('图层id');
       */
      findLayerById(id) {
        const index = this.layers.findIndex((v) => v.id === id)
        if (index > -1) {
          return this.layers.get(index)
        }
        return undefined
      }

      /**
       * 删除指定图层，需要传入一个图层对象<a id='remove'></a>
       * @param {Object} layer 要删除的图层对象
       * @example
       * //删除指定图层
       * map.findLayerById(layer);
       */
      remove(layer) {
        if (layer) {
          layer.destroy()
          this.layers.remove(layer)
          // 删除allLayers中的图层
          this.allLayers.remove(layer)
          // 删除关联的子图层
          let _allLayers = [].concat(this.allLayers.items)
          for (let i = 0; i < _allLayers.length; i++) {
            if (_allLayers[i] instanceof SubLayer) {
              const _parentLayer = _allLayers[i].layer
              if (_parentLayer && _parentLayer.id && _parentLayer.id === layer.id) {
                this.allLayers.remove(_allLayers[i])
              }
            }
          }
          _allLayers = undefined
          this.dispatchEvent(MapEventType.layerRemove, {
            type: MapEventType.layerRemove,
            target: this,
            layer
          })
        }
      }

      /**
       * 删除所有图层<a id='removeAll'></a>
       * @example
       * map.removeAll();
       */
      removeAll() {
        let _items = []
        this._isRemoveAll = true
        for (let i = 0; i < this.layers.items.length; i++) {
          _items.push(this.layers.items[i])
        }
        const self = this
        _items.forEach(function (layer) {
          self.remove(layer)
        })
        _items = undefined
        this.dispatchEvent(MapEventType.layerRemoveAll, {
          type: MapEventType.layerAdd,
          target: this
        })
        this._isRemoveAll = false
      }

      /**
       * 添加多个图层<a id='addMany'></a>
       * @param {Array} layers 要添加的图层数组
       * @example
       * map.addMany(layers);
       */
      addMany(layers) {
        if (!layers) return this
        let _isAdd = false
        if (layers instanceof Layer) {
          this.add(layers)
          _isAdd = true
        } else if (Array.isArray(layers)) {
          layers.forEach((layer) => {
            if (layer instanceof Layer) {
              this.add(layer)
            }
          })
          _isAdd = true
        } else {
          arguments.forEach((layer) => {
            if (layer instanceof Layer) {
              this.add(layer)
            }
          })
          _isAdd = true
        }

        if (_isAdd) {
          this.dispatchEvent(MapEventType.layerAddMany, {
            type: MapEventType.layerAddMany,
            target: this,
            layers
          })
        }
      }

      /**
       * 移除多个图层<a id='removeMany'></a>
       * @param {Array} layers 要移除的图层数组
       * @example
       * map.removeMany(layers);
       */
      removeMany(layers) {
        if (!layers) return this
        let _isRomove = false
        this._isRemoveMany = true
        if (layers instanceof Layer) {
          this.remove(layers)
          _isRomove = true
        } else if (Array.isArray(layers)) {
          layers.forEach((layer) => {
            if (layer instanceof Layer) {
              this.remove(layer)
            }
          })
          _isRomove = true
        } else {
          arguments.forEach((layer) => {
            if (layer instanceof Layer) {
              this.remove(layer)
            }
          })
          _isRomove = true
        }
        if (_isRomove) {
          this.dispatchEvent(MapEventType.layerRemoveMany, {
            type: MapEventType.layerAddMany,
            target: this,
            layers
          })
        }
        this._isRemoveMany = false
      }

      /**
       * 调整图层顺序<a id='reorder'></a>
       * @param {Object} layer 要调整顺序的图层
       * @param {Number} index 指定的index
       * @example
       * map.reorder(layer, '要移动到的index');
       */
      reorder(layer, index) {
        this._reorder(layer, index)
        const self = this
        this.layers.forEach(function (_layer) {
          if (layer.id !== _layer.id) {
            self._reorder(_layer, _layer.index)
          }
        })
      }

      _reorder(layer, index) {
        layer.index = index
        const _layerSet = this._getSmallEqualLargeLayers(layer)
        if (_layerSet.equalIndexLayer) {
          this._moveEqualLayer(layer, _layerSet.equalIndexLayer)
        }
        // 如果smallIndexLayer存在
        else if (_layerSet.smallIndexLayer) {
          this._moveSmallLayer(layer, _layerSet.smallIndexLayer)
        }
        // 如果largeIndexLayers长度大于0
        if (_layerSet.largeIndexLayers.length > 0) {
          this._moveLargeLayers(layer, _layerSet.largeIndexLayers)
        }
        // 更新图层顺序
        layer._updateIndex()
        for (let i = 0; i < _layerSet.largeIndexLayers.length; i++) {
          if (_layerSet.largeIndexLayers[i].id !== layer.id) {
            _layerSet.largeIndexLayers[i]._updateIndex()
          }
        }
      }

      dispatchEvent(type, data, propagate) {
        this.fire(type, data, propagate)
        this.layers.fire(type, data, propagate)
        return this
      }

      _loadLayers() {
        this.layers.forEach((layer) => {
          this.dispatchEvent(
            MapEventType.layerAdd,
            new LayerEvent({
              type: MapEventType.layerAdd,
              target: this,
              layer
            })
          )
        })
        return this
      }

      /**
       * 设置子图层的逻辑index和realIndex
       * @private
       * @param {Object} layer 图层对象
       * @param {Number} realIndex realIndex值
       * */
      _setSubLayerIndex(layer, realIndex) {
        for (let i = 0; i < layer.layers.length; i++) {
          // 指定子图层逻辑顺序
          layer.layers[i].index = i
          // 指定子图层实际顺序
          layer.layers[i]._realIndex = realIndex + i + 1
        }
      }

      /**
       * 设置图层的实际顺序
       * @private
       * @param {Object} layer 图层对象
       * @param {Number} realIndex 从哪个index开始累加
       * */
      _setLayerAndSubLayer(layer, realIndex) {
        // 是组图层，则设置组图层的子图层的顺序
        if (layer.type === LayerType.group) {
          this._setSubLayerIndex(layer, realIndex)
        } else {
          layer._realIndex = realIndex + 1
        }
      }

      /**
       * 增加图层的realIndex对象
       * @private
       * @param {Object} layer 图层对象
       * @param {Number} addIndex 要增加的index
       * */
      _addLayerRealIndex(layer, addIndex) {
        // 是组图层
        if (layer.type === LayerType.group) {
          for (let i = 0; i < layer.layers.length; i++) {
            // 指定子图层实际顺序
            layer.layers[i]._realIndex += addIndex
          }
        } else {
          layer._realIndex += addIndex
        }
      }

      /**
       * 获取图层中最大的realIndex值
       * @private
       * @param {Array} layers 图层数组
       * @return {Number} 最大的realIndex值
       * */
      _getMaxRealIndexInLayers(layers) {
        let maxRealIndex = 0
        for (let i = 0; i < layers.length; i++) {
          if (layers[i]._realIndex > maxRealIndex) {
            maxRealIndex = layers[i]._realIndex
          }
        }
        return maxRealIndex
      }

      /**
       * 获取图层中最小的realIndex值
       * @private
       * @param {Array} layers 图层数组
       * @return {Number} 最小的realIndex值
       * */
      _getMinRealIndexInLayers(layers) {
        let minRealIndex = 0
        if (layers.length > 0) {
          minRealIndex = layers[0]._realIndex
        }
        for (let i = 0; i < layers.length; i++) {
          if (layers[i]._realIndex < minRealIndex) {
            minRealIndex = layers[i]._realIndex
          }
        }
        return minRealIndex
      }

      /**
       * 获取图层组中逻辑index最小的图层
       * @private
       * @param {Array} layers 图层数组
       * @return {Object} 逻辑index最小的图层
       * */
      _getMinIndexLayer(layers) {
        let smallerLargeLayer = undefined
        for (let i = 0; i < layers.length; i++) {
          if (!smallerLargeLayer) {
            smallerLargeLayer = layers[i]
          } else if (smallerLargeLayer.index > layers[i].index) {
            smallerLargeLayer = layers[i]
          }
        }
        return smallerLargeLayer
      }

      /**
       * 获取图层的realIndex
       * @private
       * @param {Object} layer 图层对象
       * @param {String} type 获取的方式
       * @return {Number} 图层的realIndex
       * */
      _getRealIndexInLayer(layer, type) {
        let _layerRealIndex = 0
        if (layer.type === LayerType.group) {
          if (type === 'max') {
            _layerRealIndex = this._getMaxRealIndexInLayers(layer.layers)
          } else {
            _layerRealIndex = this._getMinRealIndexInLayers(layer.layers)
          }
        } else {
          _layerRealIndex = layer._realIndex
        }
        return _layerRealIndex
      }

      /**
       * 增加逻辑index大于当前图层的图层逻辑index和realIndex
       * @private
       * @param {Object} layer 当前图层对象
       * @param {Array} largeIndexLayers 增加逻辑index大于当前图层的图层数组
       * */
      _moveLargeLayers(layer, largeIndexLayers) {
        // 获取当前图层的最大realIndex
        const _layerRealIndex = this._getRealIndexInLayer(layer, 'max')
        // 获取largeIndexLayers中index最小的图层
        const smallerLargeLayer = this._getMinIndexLayer(largeIndexLayers)
        // 获取smallerLargeLayer的最小realIndex
        const _smallerRealIndex = this._getRealIndexInLayer(
          smallerLargeLayer,
          'min'
        )
        // smallerLargeLayer的逻辑index小于当前图层的逻辑index
        // 所有largeIndexLayers的逻辑index加1
        if (smallerLargeLayer.index <= layer.index) {
          for (let i = 0; i < largeIndexLayers.length; i++) {
            // if (largeIndexLayers[i].id !== layer.id) largeIndexLayers[i].index++
          }
        }
        // smallerLargeLayer的最小realIndex小于当前图层的最大realIndex
        // 所有largeIndexLayers的realIndex加_layerRealIndex - _smallerRealIndex + 1
        if (_smallerRealIndex < _layerRealIndex) {
          for (let i = 0; i < largeIndexLayers.length; i++) {
            this._addLayerRealIndex(
              largeIndexLayers[i],
              _layerRealIndex - _smallerRealIndex + 1
            )
          }
        }
      }

      /**
       * 如果当前图层对象和摸一个图层的逻辑index相等，则将当前图层向后移动一位
       * @private
       * @param {Object} layer 当前图层对象
       * @param {Object} equalIndexLayer 和当前图层对象逻辑index相等的图层
       * */
      _moveEqualLayer(layer, equalIndexLayer) {
        // 逻辑顺序加1
        // layer.index++
        let _realIndex = 0
        // index相等的图层不是组图层
        if (equalIndexLayer.type !== LayerType.group) {
          _realIndex = equalIndexLayer._realIndex
        }
        // index相等的图层是组图层
        else {
          // 找到其中最大的realIndex
          _realIndex = this._getMaxRealIndexInLayers(equalIndexLayer.layers)
        }
        this._setLayerAndSubLayer(layer, _realIndex)
      }

      /**
       * 如果当前图层的realIndex小于等于离的最近的
       * 图层的realIndex（该图层的逻辑index和当前图层的逻辑index最接近，但不相等，图层类型为组图层）
       * 则增加当前图层的realIndex，如果大于，则直接设置
       * @private
       * @param {Object} layer 当前图层对象
       * @param {Object} smallIndexLayer 里的最近的图层对象
       * */
      _moveSmallLayer(layer, smallIndexLayer) {
        let _realIndex
        if (smallIndexLayer.type === LayerType.group) {
          let sIndex = 0
          // 找到其中最大的realIndex
          _realIndex = this._getMaxRealIndexInLayers(smallIndexLayer.layers)
          for (let i = 0; i < smallIndexLayer.layers.length; i++) {
            if (smallIndexLayer.layers[i]._realIndex > sIndex) {
              sIndex = smallIndexLayer.layers[i]._realIndex
            }
          }
        } else {
          _realIndex = smallIndexLayer._realIndex
        }
        if (_realIndex >= layer.index) {
          this._setLayerAndSubLayer(layer, _realIndex)
        } else {
          this._setLayerAndSubLayer(layer, layer.index - 1)
        }
      }

      /**
       * 获取逻辑index小于、等于和大于当前图层的图层
       * @private
       * @param {Object} layer 当前图层
       * @return {Object} 图层集合
       * */
      _getSmallEqualLargeLayers(layer) {
        // index小于当前图层的图层
        let smallIndexLayer = undefined
        // index等于当前图层的图层
        let equalIndexLayer = undefined
        // index大于当前图层的图层数组
        const largeIndexLayers = []
        // 遍历当前数组，将图层分为index小于当前图层、等于当前图层和大于当前图层两组
        for (let i = 0; i < this.layers.items.length; i++) {
          if (this.layers.items[i].index < layer.index) {
            if (!smallIndexLayer) {
              smallIndexLayer = this.layers.items[i]
            } else if (smallIndexLayer.index < this.layers.items[i].index) {
              smallIndexLayer = this.layers.items[i]
            }
          } else if (
            this.layers.items[i].index === layer.index &&
            this.layers.items[i].id !== layer.id
          ) {
            equalIndexLayer = this.layers.items[i]
          } else {
            largeIndexLayers.push(this.layers.items[i])
          }
        }

        return {
          smallIndexLayer,
          equalIndexLayer,
          largeIndexLayers
        }
      }

      /**
       * 设置图层在当前图层组中的顺序
       * @private
       * @param {Object} layer 添加的图层
       * */
      _setLayerIndex(layer) {
        let _realIndex = 0
        // 没有指定顺序，则按找先来后到的顺序排列
        if (layer.index === undefined) {
          // 指定逻辑顺序
          layer.index = this.layers.items.length
          // 图层数量为0
          if (this.layers.items.length === 0) {
            this._setLayerAndSubLayer(layer, layer.index - 1)
          }
          // 图层数量大于0，则在上一个图层的基础上加一
          else if (this.layers.items.length > 0) {
            // 找到上一个图层
            const prevLayer = this.layers.items[this.layers.items.length - 1]
            // 上一个图层不是组图层
            if (prevLayer.type !== LayerType.group) {
              this._setLayerAndSubLayer(layer, prevLayer._realIndex)
            }
            // 上一个图层是组图层
            else {
              _realIndex = this._getMaxRealIndexInLayers(prevLayer.layers)
              this._setLayerAndSubLayer(layer, _realIndex)
            }
          }
        }
        // 指定图层的index
        else {
          // 设置index
          this._setLayerAndSubLayer(layer, layer.index - 1)
          const _layerSet = this._getSmallEqualLargeLayers(layer)
          // 如果equalIndexLayer存在
          if (_layerSet.equalIndexLayer) {
            this._moveEqualLayer(layer, _layerSet.equalIndexLayer)
          }
          // 如果smallIndexLayer存在
          else if (_layerSet.smallIndexLayer) {
            this._moveSmallLayer(layer, _layerSet.smallIndexLayer)
          }
          if (_layerSet.largeIndexLayers.length > 0) {
            this._moveLargeLayers(layer, _layerSet.largeIndexLayers)
          }
        }
      }
    }

    export default Map
    Zondy.Map = Map