UNPKG

@orca-fe/x-map

Version:
41 lines (40 loc) 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const AbstractLayer_1 = tslib_1.__importDefault(require("./AbstractLayer")); class BaseLayer extends AbstractLayer_1.default { constructor(options = {}) { super(); this.add = (marker) => { this.markers.add(marker); this.dom.appendChild(marker.dom); marker.setLayer(this); }; this.remove = (marker) => { this.markers.delete(marker); if (this.dom.contains(marker.dom)) { this.dom.removeChild(marker.dom); } marker.setLayer(undefined); }; const { style } = options; const dom = document.createElement('div'); dom.style.position = 'absolute'; dom.style.top = '0'; dom.style.left = '0'; dom.style.width = '0'; dom.style.height = '0'; dom.style.zIndex = '0'; if (style) { Object.entries(style).forEach(([key, value]) => { dom.style[key] = value; }); } this.dom = dom; } getSize() { const { clientWidth, clientHeight } = this.dom; return [clientWidth, clientHeight]; } } exports.default = BaseLayer;