import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _createClass from 'babel-runtime/helpers/createClass';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _get from 'babel-runtime/helpers/get';
import _inherits from 'babel-runtime/helpers/inherits';
import _extends from 'babel-runtime/helpers/extends';
/**
 * @文件说明: Layers.CirclePointLayer 矢量圆点图层
 * @创建人: pjtools@vip.qq.com
 * @创建时间: 2020-05-22 18:14:54
 */

import BasicLayerClass, { defaultVectorLayerOptions, defaultVectorBasicOptions } from './basicLayer';
import deepmerge from 'deepmerge';

var defaultLayerOptions = deepmerge(defaultVectorLayerOptions, {
  paint: {
    'circle-color': 'rgba(255, 216, 191, 0.9)',
    'circle-opacity': 1,
    'circle-radius': 5,
    'circle-blur': 0,
    'circle-stroke-color': 'rgba(250, 84, 28, 0.8)',
    'circle-stroke-opacity': 1,
    'circle-stroke-width': 2
  },
  metadata: {
    layerTypeName: 'CirclePointLayer'
  }
});

var defaultOptions = _extends({}, defaultVectorBasicOptions);

var CirclePointLayer = function (_BasicLayerClass) {
  _inherits(CirclePointLayer, _BasicLayerClass);

  function CirclePointLayer(iMapApi, id) {
    var layerOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
    var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};

    _classCallCheck(this, CirclePointLayer);

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

    // 绑定图层实例对象
    var _this = _possibleConstructorReturn(this, (CirclePointLayer.__proto__ || Object.getPrototypeOf(CirclePointLayer)).call(this, iMapApi, id, layer, opts));

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

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


  _createClass(CirclePointLayer, [{
    key: 'setOpacity',
    value: function setOpacity(opacity) {
      _get(CirclePointLayer.prototype.__proto__ || Object.getPrototypeOf(CirclePointLayer.prototype), 'setOpacity', this).call(this, opacity, ['circle-opacity', 'circle-stroke-opacity']);
    }

    /**
     * 获取圆点的半径大小
     */

  }, {
    key: 'getRadius',
    value: function getRadius() {
      return this.getPaint('circle-radius');
    }

    /**
     * 设置圆点的半径大小
     * @param {Number} radius 圆点的半径大小
     */

  }, {
    key: 'setRadius',
    value: function setRadius(radius) {
      radius && this.setPaint('circle-radius', radius);
    }
  }]);

  return CirclePointLayer;
}(BasicLayerClass);

export default CirclePointLayer;