@orca-fe/x-map
Version:
32 lines (31 loc) • 1.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const AbstractLayer_1 = require("../AbstractLayer");
const initialPosition = '-1000px';
class BaseMarker extends AbstractLayer_1.AbstractMarker {
constructor(position, options = {}) {
super();
this.updatePosition = () => {
var _a;
if ((_a = this.layer) === null || _a === void 0 ? void 0 : _a.map) {
const pixel = this.layer.map.lnglatToPixel(this.position);
this.dom.style.top = `${Math.trunc(pixel[1])}px`;
this.dom.style.left = `${Math.trunc(pixel[0])}px`;
}
};
this.setPosition = (position) => {
this.position = position;
this.updatePosition();
};
this.getPosition = () => this.position;
const dom = document.createElement('div');
dom.style.position = 'absolute';
dom.style.top = initialPosition;
dom.style.left = initialPosition;
dom.style.width = '0';
dom.style.height = '0';
this.dom = dom;
this.position = position;
}
}
exports.default = BaseMarker;