'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.CirclePointLayer 矢量圆点图层
 * @创建人: pjtools@vip.qq.com
 * @创建时间: 2020-05-22 18:14:54
 */

var defaultLayerOptions = (0, _deepmerge2['default'])(_basicLayer.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 = (0, _extends3['default'])({}, _basicLayer.defaultVectorBasicOptions);

var CirclePointLayer = function (_BasicLayerClass) {
  (0, _inherits3['default'])(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] : {};
    (0, _classCallCheck3['default'])(this, CirclePointLayer);

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

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

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

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


  (0, _createClass3['default'])(CirclePointLayer, [{
    key: 'setOpacity',
    value: function setOpacity(opacity) {
      (0, _get3['default'])(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;
}(_basicLayer2['default']);

exports['default'] = CirclePointLayer;