@orca-fe/x-map
Version:
29 lines (28 loc) • 1.08 kB
JavaScript
import { AbstractMarker } from '../AbstractLayer';
const initialPosition = '-1000px';
export default class BaseMarker extends 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;
}
}