UNPKG

@tuoyuan/map-adapter-lib

Version:

地图适配器库

191 lines (190 loc) 5 kB
var r = Object.defineProperty; var m = (n, l, e) => l in n ? r(n, l, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[l] = e; var s = (n, l, e) => m(n, typeof l != "symbol" ? l + "" : l, e); import { EventBus as d } from "./MapEvent.js"; import { Size as p } from "./Size.js"; import { Pixel as g } from "./Pixel.js"; import { Position as c } from "./Position.js"; import { Icon as w } from "./Icon.js"; import { Label as f } from "./Label.js"; import { deepAssign as o } from "../utils/deep-assign.js"; class y extends d { constructor(e, t, i) { var a, h, b, _; super(); s(this, "_top"); /** ID */ s(this, "_id"); /** 名称 */ s(this, "_name"); /** 位置 */ s(this, "_position"); /** 样式 */ s(this, "_style"); /** 图标 */ s(this, "_icon"); /** icon基础方位 */ s(this, "_basePlacement", "center"); /** 文本标签 */ s(this, "_label"); /** 业务数据 */ s(this, "_data"); /** 是否可见 */ s(this, "_visible"); /** label基础方位 */ s(this, "_labelBasePlacement", "center"); this._top = e, i != null && i.basePlacement && (this._basePlacement = i.basePlacement, this._labelBasePlacement = i.labelBasePlacement ?? "center"), this._id = t.id, this._name = t.name, this._position = new c(...t.position), this._visible = t.visible ?? !0, this._data = t.data, this._style = o({}, e.options.style.marker, { icon: (a = t.style) == null ? void 0 : a.icon, label: (h = t.style) == null ? void 0 : h.label }), this._icon = this.genIcon(o({}, e.options.style.marker.icon, (b = t.style) == null ? void 0 : b.icon)), this._label = this.genLabel( e, o({}, e.options.label, e.options.style.marker.label, t.label, (_ = t.style) == null ? void 0 : _.label), this._icon ), this._label.listenAndUpdateVisible({ showLabel: this.showLabel.bind(this), hiddenLabel: this.hiddenLabel.bind(this) }); } genIcon(e) { return new w( this._basePlacement, e.image, new p(e.imageSize.width, e.imageSize.height), new g(e.offset.x, e.offset.y), e.placement ); } genLabel(e, t, i) { return new f(e, { canShow: t.visible !== !1, minShowZoom: t.minShowZoom, color: t.color, backgroundColor: t.backgroundColor, fontSize: t.fontSize, placement: t.placement, visible: t.visible, text: t.text, basePlacement: this._labelBasePlacement, icon: i }); } /** ID */ get id() { return this._id; } /** 名称 */ get name() { return this._name; } /** 位置 */ get position() { return this._position; } /** 图标 */ get icon() { return this._icon; } /** 文本标签 */ get label() { return this._label; } /** 业务数据 */ get data() { return this._data; } /** * 设置名称 * @param name 名称 */ setName(e) { this._name = e; } /** * 设置位置 * @param position 位置 */ setPosition(e) { this._position = new c(...e); } /** * 设置图标 * @param icon 图标 */ setIcon(e) { var t, i; (i = (t = this._icon) == null ? void 0 : t.setImage) == null || i.call(t, e); } /** * 设置文本标签 * @param text 文本 */ setLabel(e) { var t, i; (i = (t = this._label) == null ? void 0 : t.setText) == null || i.call(t, e); } /** * 设置业务数据 * @param data 业务数据 */ setData(e) { this._data = e; } /** * 设置样式 * @param style 样式 */ setStyle(e) { var t, i, a, h, b; this._style = o({}, this._style, e), this._icon = this.genIcon(o({}, this._top.options.style.marker.icon, (t = this._style) == null ? void 0 : t.icon)), this._label = this.genLabel( this._top, o( {}, this._top.options.label, this._top.options.style.marker.label, { text: (i = this._label) == null ? void 0 : i.text, minShowZoom: (a = this._label) == null ? void 0 : a.minShowZoom, visible: (h = this._label) == null ? void 0 : h.visible }, (b = this._style) == null ? void 0 : b.label ), this._icon ), this._label.listenAndUpdateVisible({ showLabel: this.showLabel.bind(this), hiddenLabel: this.hiddenLabel.bind(this) }); } /** * 显示,icon、label */ show() { var e; this._visible = !0, (e = this._label) != null && e.canShow && this.showLabel(); } /** * 隐藏,icon、label */ hidden() { this._visible = !1, this.hiddenLabel(); } /** * 显示label */ showLabel() { var e, t; (t = (e = this._label) == null ? void 0 : e.setVisible) == null || t.call(e, !0); } /** * 隐藏label */ hiddenLabel() { var e, t; (t = (e = this._label) == null ? void 0 : e.setVisible) == null || t.call(e, !1); } } class z extends y { } export { z as AbstractMarker, y as BaseMarker };