UNPKG

@tuoyuan/map-adapter-lib

Version:

地图适配器库

2 lines (1 loc) 3.29 kB
"use strict";var d=Object.defineProperty;var m=(n,l,e)=>l in n?d(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);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./MapEvent.js"),u=require("./Size.js"),p=require("./Pixel.js"),_=require("./Position.js"),w=require("./Icon.js"),y=require("./Label.js"),o=require("../utils/deep-assign.js");class r extends g.EventBus{constructor(e,t,i){var a,h,b,c;super();s(this,"_top");s(this,"_id");s(this,"_name");s(this,"_position");s(this,"_style");s(this,"_icon");s(this,"_basePlacement","center");s(this,"_label");s(this,"_data");s(this,"_visible");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 _.Position(...t.position),this._visible=t.visible??!0,this._data=t.data,this._style=o.deepAssign({},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.deepAssign({},e.options.style.marker.icon,(b=t.style)==null?void 0:b.icon)),this._label=this.genLabel(e,o.deepAssign({},e.options.label,e.options.style.marker.label,t.label,(c=t.style)==null?void 0:c.label),this._icon),this._label.listenAndUpdateVisible({showLabel:this.showLabel.bind(this),hiddenLabel:this.hiddenLabel.bind(this)})}genIcon(e){return new w.Icon(this._basePlacement,e.image,new u.Size(e.imageSize.width,e.imageSize.height),new p.Pixel(e.offset.x,e.offset.y),e.placement)}genLabel(e,t,i){return new y.Label(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})}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}setName(e){this._name=e}setPosition(e){this._position=new _.Position(...e)}setIcon(e){var t,i;(i=(t=this._icon)==null?void 0:t.setImage)==null||i.call(t,e)}setLabel(e){var t,i;(i=(t=this._label)==null?void 0:t.setText)==null||i.call(t,e)}setData(e){this._data=e}setStyle(e){var t,i,a,h,b;this._style=o.deepAssign({},this._style,e),this._icon=this.genIcon(o.deepAssign({},this._top.options.style.marker.icon,(t=this._style)==null?void 0:t.icon)),this._label=this.genLabel(this._top,o.deepAssign({},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)})}show(){var e;this._visible=!0,(e=this._label)!=null&&e.canShow&&this.showLabel()}hidden(){this._visible=!1,this.hiddenLabel()}showLabel(){var e,t;(t=(e=this._label)==null?void 0:e.setVisible)==null||t.call(e,!0)}hiddenLabel(){var e,t;(t=(e=this._label)==null?void 0:e.setVisible)==null||t.call(e,!1)}}class L extends r{}exports.AbstractMarker=L;exports.BaseMarker=r;