UNPKG

@orca-fe/x-map

Version:
35 lines (34 loc) 1.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const defs_1 = require("../defs"); const AbstractLayer_1 = tslib_1.__importDefault(require("./AbstractLayer")); const svgNS = 'http://www.w3.org/2000/svg'; class SvgLayer extends AbstractLayer_1.default { constructor(options = {}) { super(); const dom = document.createElementNS(svgNS, 'svg'); dom.style.position = 'absolute'; dom.style.top = `${defs_1.SVG_OFFSET_TOP}px`; dom.style.left = '0'; dom.style.overflow = 'visible'; this.dom = dom; } add(marker) { this.markers.add(marker); this.dom.appendChild(marker.dom); marker.setLayer(this); } remove(marker) { this.markers.delete(marker); if (this.dom.contains(marker.dom)) { this.dom.removeChild(marker.dom); } marker.setLayer(undefined); } getSize() { const { clientWidth, clientHeight } = this.dom; return [clientWidth, clientHeight]; } } exports.default = SvgLayer;