'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _get2 = require('babel-runtime/helpers/get');

var _get3 = _interopRequireDefault(_get2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _extends2 = require('babel-runtime/helpers/extends');

var _extends3 = _interopRequireDefault(_extends2);

var _basicLayer = require('./basicLayer');

var _basicLayer2 = _interopRequireDefault(_basicLayer);

var _deepmerge = require('deepmerge');

var _deepmerge2 = _interopRequireDefault(_deepmerge);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

/**
 * @文件说明: Layers.BackgroundLayer 背景色矢量图层
 * @创建人: pjtools@vip.qq.com
 * @创建时间: 2020-05-22 15:01:49
 */

var defaultLayerOptions = (0, _deepmerge2['default'])(_basicLayer.defaultVectorLayerOptions, {
  paint: {
    'background-color': 'rgba(0, 0, 0, 1)',
    'background-opacity': 1
  },
  metadata: {
    layerTypeName: 'BackgroundLayer'
  }
});

var defaultOptions = (0, _extends3['default'])({}, _basicLayer.defaultVectorBasicOptions);

var BackgroundLayer = function (_BasicLayerClass) {
  (0, _inherits3['default'])(BackgroundLayer, _BasicLayerClass);

  function BackgroundLayer(iMapApi, id) {
    var layerOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
    var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
    (0, _classCallCheck3['default'])(this, BackgroundLayer);

    var opts = _deepmerge2['default'].all([{}, defaultOptions, options || {}]);
    opts.opacityPaints = ['background-opacity'];
    // 合并原生Layer图层属性
    var layer = _deepmerge2['default'].all([{}, defaultLayerOptions, layerOptions || {}]);
    layer.type = 'background';
    // 继承矢量图层基类

    // 绑定图层实例对象
    var _this = (0, _possibleConstructorReturn3['default'])(this, (BackgroundLayer.__proto__ || Object.getPrototypeOf(BackgroundLayer)).call(this, iMapApi, id, layer, opts));

    _this.mapLayer && (_this.mapLayer._instance = _this);
    return _this;
  }

  /**
   * 设置图层的整体透明度
   * @param {Number} opacity 待设定的透明度
   */


  (0, _createClass3['default'])(BackgroundLayer, [{
    key: 'setOpacity',
    value: function setOpacity(opacity) {
      (0, _get3['default'])(BackgroundLayer.prototype.__proto__ || Object.getPrototypeOf(BackgroundLayer.prototype), 'setOpacity', this).call(this, opacity, ['background-opacity']);
    }

    /**
     * 获取图层的背景色
     */

  }, {
    key: 'getColor',
    value: function getColor() {
      return this.getPaint('background-color');
    }

    /**
     * 设置图层的背景色
     * @param {String} color 待设定的背景色
     */

  }, {
    key: 'setColor',
    value: function setColor(color) {
      color && this.setPaint('background-color', color);
    }
  }]);
  return BackgroundLayer;
}(_basicLayer2['default']);

exports['default'] = BackgroundLayer;