'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);

var _methodsUtil = require('../../../_util/methods-util');

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

var defaultLayerOptions = (0, _deepmerge2['default'])(_basicLayer.defaultVectorLayerOptions, {
  paint: {
    'fill-extrusion-base': 0,
    'fill-extrusion-color': 'rgba(170, 170, 170, 1)',
    'fill-extrusion-height': 0,
    'fill-extrusion-opacity': 0.9,
    'fill-extrusion-vertical-gradient': true
  },
  metadata: {
    layerTypeName: 'FillExtrusionLayer'
  }
}); /**
     * @文件说明: Layers.FillExtrusionLayer 3D填充图层
     * @创建人: pjtools@vip.qq.com
     * @创建时间: 2020-05-25 15:35:15
     */

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

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

  function FillExtrusionLayer(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, FillExtrusionLayer);

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

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

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

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


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

    /**
     * 获取3D填充的颜色属性
     */

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

    /**
     * 设置3D填充的颜色属性
     * @param {String} color 待设定的颜色值
     */

  }, {
    key: 'setColor',
    value: function setColor(color) {
      color && this.setPaint('fill-extrusion-color', color);
    }

    /**
     * 获取3D填充的拉起高度
     */

  }, {
    key: 'getHeight',
    value: function getHeight() {
      return this.getPaint('fill-extrusion-height');
    }

    /**
     * 设置3D填充的拉起高度
     * @param {Number} height 待设定的3D拉起高度
     */

  }, {
    key: 'setHeight',
    value: function setHeight(height) {
      !(0, _methodsUtil.isEmpty)(height) && this.setPaint('fill-extrusion-height', height);
    }

    /**
     * 获取3D填充的基座高度（即离地高度）
     */

  }, {
    key: 'getBaseHeight',
    value: function getBaseHeight() {
      return this.getPaint('fill-extrusion-base');
    }

    /**
     * 设置3D填充的基座高度（即离地高度）
     * @param {Number} height 待设定的离地高度
     */

  }, {
    key: 'setBaseHeight',
    value: function setBaseHeight(height) {
      !(0, _methodsUtil.isEmpty)(height) && this.setPaint('fill-extrusion-base', height);
    }
  }]);
  return FillExtrusionLayer;
}(_basicLayer2['default']);

exports['default'] = FillExtrusionLayer;