'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: {
    'line-color': 'rgba(250, 84, 28, 0.8)',
    'line-opacity': 1,
    'line-width': 4,
    'line-blur': 0,
    'line-offset': 0,
    'line-gap-width': 0
  },
  layout: {
    'line-cap': 'round',
    'line-join': 'round'
  },
  metadata: {
    layerTypeName: 'LineLayer'
  }
}); /**
     * @文件说明: Layers.LineLayer 矢量线图层
     * @创建人: pjtools@vip.qq.com
     * @创建时间: 2020-05-25 10:05:46
     */

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

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

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

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

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

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

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


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

    /**
     * 获取矢量线的颜色属性
     */

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

    /**
     * 设置矢量线的颜色属性
     * @param {String} color 待设定的颜色值
     */

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

    /**
     * 获取矢量线的宽度
     */

  }, {
    key: 'getLineWidth',
    value: function getLineWidth() {
      return this.getPaint('line-width');
    }

    /**
     * 设置矢量线的宽度
     * @param {Number} width 待设定的线宽度
     */

  }, {
    key: 'setLineWidth',
    value: function setLineWidth(width) {
      !(0, _methodsUtil.isEmpty)(width) && this.setPaint('line-width', width);
    }
  }]);
  return LineLayer;
}(_basicLayer2['default']);

exports['default'] = LineLayer;