@orca-fe/x-map
Version:
29 lines (28 loc) • 1.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const defs_1 = require("../../defs");
const SvgLine_1 = tslib_1.__importDefault(require("./SvgLine"));
const math_1 = require("../../utils/math");
class SvgArcLine extends SvgLine_1.default {
constructor(options) {
super(options);
this.setAlpha = (alpha) => {
this.alpha = alpha;
this.updatePosition();
};
this.updatePosition = () => {
var _a;
if ((_a = this.layer) === null || _a === void 0 ? void 0 : _a.map) {
const { map } = this.layer;
const [fromPixel, toPixel] = [this.from, this.to].map(position => map.lnglatToPixel(position));
const bAlpha = toPixel[0] < fromPixel[0] ? 1 : -1;
const { cp } = (0, math_1.getCPoints)(fromPixel, toPixel, this.alpha * bAlpha);
this.dom.setAttribute('d', `M${fromPixel[0]} ${fromPixel[1] - defs_1.SVG_OFFSET_TOP}Q${Math.round(cp[0])} ${Math.round(cp[1] - defs_1.SVG_OFFSET_TOP)} ${toPixel[0]} ${toPixel[1] - defs_1.SVG_OFFSET_TOP}`);
}
};
const { alpha = 3 } = options;
this.alpha = alpha;
}
}
exports.default = SvgArcLine;