"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IconLayer = void 0;
var tslib_1 = require("tslib");
var util_1 = require("@antv/util");
var composite_layer_1 = require("../../core/composite-layer");
var text_layer_1 = require("../../core-layers/text-layer");
var point_layer_1 = require("../../core-layers/point-layer");
var adaptor_1 = require("./adaptor");
var constants_1 = require("./constants");
var label_layer_1 = require("../common/label-layer");
var constants_2 = require("../../core/constants");
var IconLayer = /** @class */ (function (_super) {
    tslib_1.__extends(IconLayer, _super);
    function IconLayer(options) {
        var _this = _super.call(this, options) || this;
        /**
         * 图层交互状态配置
         */
        _this.layerState = constants_1.DEFAULT_STATE;
        /**
         * 复合图层类型
         */
        _this.type = composite_layer_1.CompositeLayer.LayerType.IconImageLayer;
        /**
         * 图层是否具有交互属性
         */
        _this.interaction = true;
        return _this;
        // this.initSubLayersEvent();
    }
    Object.defineProperty(IconLayer.prototype, "layer", {
        /**
         * 主图层
         */
        get: function () {
            return this.iconLayer;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IconLayer.prototype, "iconLayer", {
        /**
         * 图标图层
         */
        get: function () {
            return this.subLayers.getLayer('iconLayer');
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IconLayer.prototype, "labelLayer", {
        /**
         * 标注文本图层
         */
        get: function () {
            return this.subLayers.getLayer('labelLayer');
        },
        enumerable: false,
        configurable: true
    });
    /**
     * 添加到场景
     */
    IconLayer.prototype.addTo = function (scene) {
        this.scene = scene;
        this.initAssets();
        this.subLayers.addTo(scene);
        this.emit(constants_2.CompositeLayerEvent.ADD);
    };
    /**
     * 获取图标图层配置项
     */
    IconLayer.prototype.getIconLayerOptions = function () {
        var _a = (0, util_1.omit)(this.options, ['source']), visible = _a.visible, minZoom = _a.minZoom, maxZoom = _a.maxZoom, _b = _a.zIndex, zIndex = _b === void 0 ? 0 : _b, radius = _a.radius, opacity = _a.opacity, icon = _a.icon, color = _a.color, iconStyle = _a.iconStyle, baseConfig = tslib_1.__rest(_a, ["visible", "minZoom", "maxZoom", "zIndex", "radius", "opacity", "icon", "color", "iconStyle"]);
        var defaultState = this.layerState;
        var fillState = {
            active: false,
            select: false,
        };
        var fillStyle = tslib_1.__assign({ opacity: opacity }, iconStyle);
        var options = tslib_1.__assign(tslib_1.__assign({}, baseConfig), { visible: visible, minZoom: minZoom, maxZoom: maxZoom, zIndex: zIndex, shape: icon, size: radius, state: fillState, color: color, style: fillStyle });
        return options;
    };
    IconLayer.prototype.createSubLayers = function () {
        var source = this.source;
        this.layerState = (0, adaptor_1.getDefaultState)(this.options.state);
        // 映射图标图层
        var iconLayer = new point_layer_1.PointLayer(tslib_1.__assign(tslib_1.__assign({}, this.getIconLayerOptions()), { id: 'iconLayer', source: source }));
        var labelLayer = new text_layer_1.TextLayer(tslib_1.__assign(tslib_1.__assign({}, (0, label_layer_1.getLabelLayerOptions)(this.options)), { id: 'labelLayer', source: source }));
        var subLayers = [iconLayer, labelLayer];
        return subLayers;
    };
    IconLayer.prototype.updateSubLayers = function (options) {
        this.iconLayer.update(this.getIconLayerOptions());
        this.labelLayer.update((0, label_layer_1.getLabelLayerOptions)(this.options));
    };
    /**
     * 默认配置项
     */
    IconLayer.DefaultOptions = constants_1.DEFAULT_OPTIONS;
    return IconLayer;
}(composite_layer_1.CompositeLayer));
exports.IconLayer = IconLayer;
//# sourceMappingURL=icon.js.map