@tuoyuan/map-adapter-lib
Version:
地图适配器库
57 lines (56 loc) • 1.71 kB
JavaScript
var f = Object.defineProperty;
var h = (s, e, t) => e in s ? f(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
var i = (s, e, t) => h(s, typeof e != "symbol" ? e + "" : e, t);
import { Size as c } from "./Size.js";
import { Pixel as m } from "./Pixel.js";
class g {
constructor(e, t, n, l, a) {
/** 图片地址 */
i(this, "_image");
/** 地图显示的基础方位 */
i(this, "_basePlacement");
/** 显示尺寸 */
i(this, "_size");
/** 显示方位 */
i(this, "_placement");
/** 偏移量 */
i(this, "_offset");
this._basePlacement = e, this._image = t, this._size = n || new c(36, 36), this._offset = l, this._placement = a;
}
get image() {
return this._image;
}
get size() {
return this._size;
}
get offset() {
return this._offset;
}
get placement() {
return this._placement;
}
getRealOffset() {
const e = {
x: 0,
y: 0
};
this._basePlacement.includes("top") && (e.y += 0.5), this._basePlacement.includes("bottom") && (e.y -= 0.5), this._basePlacement.includes("left") && (e.x += 0.5), this._basePlacement.includes("right") && (e.x -= 0.5), this.placement.includes("top") && (e.y -= 0.5), this.placement.includes("bottom") && (e.y += 0.5), this.placement.includes("left") && (e.x -= 0.5), this.placement.includes("right") && (e.x += 0.5);
let t = this.size.width * e.x, n = this.size.height * e.y;
return t += this.offset.x, n += this.offset.y, new m(t, n);
}
setImage(e) {
this._image = e;
}
setSize(e) {
this._size = e;
}
setOffset(e) {
this._offset = e;
}
setPlacement(e) {
this._placement = e;
}
}
export {
g as Icon
};