UNPKG

ol-plot-tool

Version:
2,083 lines 126 kB
var he = Object.defineProperty; var le = (o, s, t) => s in o ? he(o, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[s] = t; var l = (o, s, t) => (le(o, typeof s != "symbol" ? s + "" : s, t), t); import { Overlay as nt, Map as M, Observable as ht, Feature as k } from "ol"; import ce, { createBox as ue } from "ol/interaction/Draw"; import ge from "ol/interaction/DoubleClickZoom"; import { Style as tt, Fill as K, Stroke as lt, Circle as fe, Icon as ct, RegularShape as xt, Text as pe } from "ol/style"; import _t from "ol/Overlay"; import { Group as de, Vector as Z } from "ol/layer"; import { Vector as ot } from "ol/source"; import Tt from "ol/interaction/DragPan"; import Pe from "ol/events/Event"; import { Point as ut, LineString as X, Polygon as x, Geometry as me } from "ol/geom"; import { fromExtent as ye } from "ol/geom/Polygon"; import { boundingExtent as we, getSize as Ce, getBottomLeft as Ae, getTopRight as Me, buffer as ve } from "ol/extent"; import { asArray as z, asString as Ct } from "ol/color"; const S = 100, C = Math.PI / 2, gt = 1e-4, Lt = "ol-plot-vector-layer", G = "plot-helper-control-point-div", At = "plot-helper-hidden-div", Mt = { // 默认文本框样式 borderRadius: "2px", fontSize: "12px", outline: 0, overflow: "hidden", boxSizing: "border-box", border: "1px solid #eeeeee", fontFamily: "Helvetica Neue,Helvetica,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Noto Sans CJK SC,WenQuanYi Micro Hei,Arial,sans-serif", color: "#010500", fontWeight: 400, padding: "3px", fontStretch: "normal", lineHeight: "normal", textAlign: "left", marginLeft: "auto", marginRight: "auto", width: "auto", height: "auto", background: "rgb(255, 255, 255)", fontStyle: "", fontVariant: "" }, v = (o, s) => Math.sqrt((o[0] - s[0]) ** 2 + (o[1] - s[1]) ** 2), ft = (o) => { let s = 0; return o && Array.isArray(o) && o.length > 0 && o.forEach((t, e) => { e < o.length - 1 && (s += v(t, o[e + 1])); }), s; }, I = (o) => ft(o) ** 0.99, T = (o, s) => [(o[0] + s[0]) / 2, (o[1] + s[1]) / 2], Ft = (o, s, t) => { const e = [(o[0] + s[0]) / 2, (o[1] + s[1]) / 2], i = [e[0] - o[1] + s[1], e[1] + o[0] - s[0]], n = [(o[0] + t[0]) / 2, (o[1] + t[1]) / 2], r = [n[0] - o[1] + t[1], n[1] + o[0] - t[0]]; return Ee(e, i, n, r); }, Ee = (o, s, t, e) => { if (o[1] === s[1]) { const c = (e[0] - t[0]) / (e[1] - t[1]) * (o[1] - t[1]) + t[0], u = o[1]; return [c, u]; } if (t[1] === e[1]) { const c = (s[0] - o[0]) / (s[1] - o[1]) * (t[1] - o[1]) + o[0], u = t[1]; return [c, u]; } const i = (s[0] - o[0]) / (s[1] - o[1]), n = (e[0] - t[0]) / (e[1] - t[1]), r = (i * o[1] - o[0] - n * t[1] + t[0]) / (i - n); return [i * r - i * o[1] + o[0], r]; }, R = (o, s) => { let t = 0; const e = Math.asin(Math.abs(s[1] - o[1]) / v(o, s)); return s[1] >= o[1] && s[0] >= o[0] ? t = e + Math.PI : s[1] >= o[1] && s[0] < o[0] ? t = Math.PI * 2 - e : s[1] < o[1] && s[0] < o[0] ? t = e : s[1] < o[1] && s[0] >= o[0] && (t = Math.PI - e), t; }, J = (o, s, t) => { const e = R(s, o) - R(s, t); return e < 0 ? e + Math.PI * 2 : e; }, $ = (o, s, t) => (t[1] - o[1]) * (s[0] - o[0]) > (s[1] - o[1]) * (t[0] - o[0]), pt = (o, s, t, e, i) => { o = Math.max(Math.min(o, 1), 0); const [n, r] = [1 - o, o * o], a = r * o, h = n * n, c = h * n, u = c * s[0] + 3 * h * o * t[0] + 3 * n * r * e[0] + a * i[0], g = c * s[1] + 3 * h * o * t[1] + 3 * n * r * e[1] + a * i[1]; return [u, g]; }, P = (o, s, t, e, i) => { const n = R(o, s), r = i ? n + t : n - t, a = e * Math.cos(r), h = e * Math.sin(r); return [s[0] + a, s[1] + h]; }, dt = (o, s, t, e) => { let [i, n, r, a] = [0, 0, [], e - t]; a = a < 0 ? a + Math.PI * 2 : a; for (let h = 0; h <= 100; h++) { const c = t + a * h / 100; i = o[0] + s * Math.cos(c), n = o[1] + s * Math.sin(c), r.push([i, n]); } return r; }, q = (o, s, t, e) => { const i = Pt(s, t, e); let [n, r, a, h, c] = [ [0, 0], [0, 0], 0, 0, 0 ]; const u = Math.sqrt(i[0] * i[0] + i[1] * i[1]), g = i[0] / u, f = i[1] / u, m = v(s, t), d = v(t, e); return u > gt ? $(s, t, e) ? (a = o * m, h = t[0] - a * f, c = t[1] + a * g, n = [h, c], a = o * d, h = t[0] + a * f, c = t[1] - a * g, r = [h, c]) : (a = o * m, h = t[0] + a * f, c = t[1] - a * g, n = [h, c], a = o * d, h = t[0] - a * f, c = t[1] + a * g, r = [h, c]) : (h = t[0] + o * (s[0] - t[0]), c = t[1] + o * (s[1] - t[1]), n = [h, c], h = t[0] + o * (e[0] - t[0]), c = t[1] + o * (e[1] - t[1]), r = [h, c]), [n, r]; }, Pt = (o, s, t) => { let e = o[0] - s[0], i = o[1] - s[1]; const n = Math.sqrt(e * e + i * i); e /= n, i /= n; let r = t[0] - s[0], a = t[1] - s[1]; const h = Math.sqrt(r * r + a * a); r /= h, a /= h; const c = e + r, u = i + a; return [c, u]; }, xe = (o, s) => { let [t, e, i, n, r] = [ o[0], o[1], o[2], 0, 0 ]; const h = q(0, t, e, i)[0], c = Pt(t, e, i); if (Math.sqrt(c[0] * c[0] + c[1] * c[1]) > gt) { const g = T(t, e), f = t[0] - g[0], m = t[1] - g[1], y = 2 / v(t, e), A = -y * m, w = y * f, E = A * A - w * w, O = 2 * A * w, L = w * w - A * A, N = h[0] - g[0], D = h[1] - g[1]; n = g[0] + E * N + O * D, r = g[1] + O * N + L * D; } else n = t[0] + s * (e[0] - t[0]), r = t[1] + s * (e[1] - t[1]); return [n, r]; }, _e = (o, s) => { const t = o.length, e = o[t - 3], i = o[t - 2], n = o[t - 1], a = q(0, e, i, n)[1], h = Pt(e, i, n), c = Math.sqrt(h[0] * h[0] + h[1] * h[1]); let [u, g] = [0, 0]; if (c > gt) { const f = T(i, n), m = n[0] - f[0], d = n[1] - f[1], A = 2 / v(i, n), w = -A * d, E = A * m, O = w * w - E * E, L = 2 * w * E, N = E * E - w * w, D = a[0] - f[0], B = a[1] - f[1]; u = f[0] + O * D + L * B, g = f[1] + L * D + N * B; } else u = n[0] + s * (i[0] - n[0]), g = n[1] + s * (i[1] - n[1]); return [u, g]; }, Te = (o, s) => { const t = xe(s, o); let [e, i, n, r] = [null, null, null, [t]]; const a = []; for (let c = 0; c < s.length - 2; c++) { [e, i, n] = [s[c], s[c + 1], s[c + 2]]; const u = q(o, e, i, n); r = r.concat(u); } const h = _e(s, o); h && r.push(h); for (let c = 0; c < s.length - 1; c++) { e = s[c], i = s[c + 1], a.push(e); for (let u = 0; u < S; u++) { const g = pt(u / S, e, r[c * 2], r[c * 2 + 1], i); a.push(g); } a.push(i); } return a; }, V = function(o) { if (o.length <= 2) return o; const s = [], t = o.length - 1; for (let e = 0; e <= 1; e += 0.01) { let [i, n] = [0, 0]; for (let r = 0; r <= t; r++) { const a = Le(t, r), h = e ** r, c = (1 - e) ** (t - r); i += a * h * c * o[r][0], n += a * h * c * o[r][1]; } s.push([i, n]); } return s.push(o[t]), s; }, et = (o) => { let s = 1; switch (!0) { case o <= 1: s = 1; break; case o === 2: s = 2; break; case o === 3: s = 6; break; case o === 24: s = 24; break; case o === 5: s = 120; break; default: for (let t = 1; t <= o; t++) s *= t; break; } return s; }, Le = (o, s) => et(o) / (et(s) * et(o - s)), H = (o) => { if (o.length <= 2) return o; const [s, t] = [2, []], e = o.length - s - 1; t.push(o[0]); for (let i = 0; i <= e; i++) for (let n = 0; n <= 1; n += 0.05) { let [r, a] = [0, 0]; for (let h = 0; h <= s; h++) { const c = Fe(h, n); r += c * o[i + h][0], a += c * o[i + h][1]; } t.push([r, a]); } return t.push(o[o.length - 1]), t; }, Fe = (o, s) => { let t = 0; return o === 0 ? t = (s - 1) ** 2 / 2 : o === 1 ? t = (-2 * s ** 2 + 2 * s + 1) / 2 : o === 2 && (t = s ** 2 / 2), t; }; function rt(o = !1) { function s(t) { return t ? (t ^ Math.random() * 16 >> t / 4).toString(16) : ([1e7] + -[1e3] + -4e3 + -8e3 + -1e11).replace(/[018]/g, s); } return o ? s().replace(/-/g, "") : s(); } const vt = (o) => { const s = typeof o; return o !== null && (s === "object" || s === "function"); }, It = (o, s) => { for (const t in s) vt(s[t]) && vt(o[t]) ? It(o[t], s[t]) : o[t] = s[t]; return o; }; function mt(o, s) { o.forEach((t) => { s[t] && (s[t] = s[t].bind(s)); }); } const W = function(o, s) { try { let t = null; if (o) { const e = o.getLayers().getArray(); t = kt(e, "layerName", s); } return t; } catch (t) { return console.log(t), null; } }, kt = function(o, s, t) { let e = null; return o.length > 0 && o.every((i) => { if (i instanceof de) { const n = i.getLayers().getArray(); return e = kt(n, s, t), !e; } return i.get(s) === t ? (e = i, !1) : !0; }), e; }, bt = function(o, s, t) { try { if (o) { let e = W(o, s); if (e instanceof Z || (e = null), e || t && t.create && (e = new Z({ // @ts-ignore this is unsafe layerName: s, params: t, layerType: "vector", source: new ot({ wrapX: !1 }), style: new tt({ fill: new K({ color: "rgba(67, 110, 238, 0.4)" }), stroke: new lt({ color: "#4781d9", width: 2 }), image: new fe({ radius: 7, fill: new K({ color: "#ffcc33" }) }) }) })), o && e) { t && t.hasOwnProperty("selectable") && e.set("selectable", t.selectable); const i = W(o, s); (!i || !(i instanceof Z)) && o.addLayer(e); } return e; } } catch (e) { console.error(e); } }; var p = /* @__PURE__ */ ((o) => (o.TEXTAREA = "TextArea", o.ARC = "Arc", o.CURVE = "Curve", o.GATHERING_PLACE = "GatheringPlace", o.POLYLINE = "Polyline", o.FREEHANDLINE = "FreeHandLine", o.POINT = "Point", o.PENNANT = "Pennant", o.RECTANGLE = "RectAngle", o.CIRCLE = "Circle", o.ELLIPSE = "Ellipse", o.LUNE = "Lune", o.SECTOR = "Sector", o.CLOSED_CURVE = "ClosedCurve", o.POLYGON = "Polygon", o.FREE_POLYGON = "FreePolygon", o.ATTACK_ARROW = "AttackArrow", o.DOUBLE_ARROW = "DoubleArrow", o.STRAIGHT_ARROW = "StraightArrow", o.FINE_ARROW = "FineArrow", o.ASSAULT_DIRECTION = "AssaultDirection", o.TAILED_SQUAD_COMBAT = "TailedSquadCombat", o.TAILED_ATTACK_ARROW = "TailedAttackArrow", o.SQUAD_COMBAT = "SquadCombat", o.RECTFLAG = "RectFlag", o.TRIANGLEFLAG = "TriangleFlag", o.CURVEFLAG = "CurveFlag", o.RECTINCLINED1 = "RectInclined1", o.RECTINCLINED2 = "RectInclined2", o))(p || {}), Y = /* @__PURE__ */ new Map(); function Ie(o) { var s = Y.get(o); s && s.destroy(); } function ke(o) { var s = Y.get(o); s && s.update(); } var U = null; typeof window > "u" ? ((U = function(o) { return o; }).destroy = function(o) { return o; }, U.update = function(o) { return o; }) : ((U = function(o, s) { return o && Array.prototype.forEach.call(o.length ? o : [o], function(t) { return function(e) { if (e && e.nodeName && e.nodeName === "TEXTAREA" && !Y.has(e)) { var i, n = null, r = window.getComputedStyle(e), a = (i = e.value, function() { c({ testForHeightReduction: i === "" || !e.value.startsWith(i), restoreTextAlign: null }), i = e.value; }), h = (function(g) { e.removeEventListener("autosize:destroy", h), e.removeEventListener("autosize:update", u), e.removeEventListener("input", a), window.removeEventListener("resize", u), Object.keys(g).forEach(function(f) { return e.style[f] = g[f]; }), Y.delete(e); }).bind(e, { height: e.style.height, resize: e.style.resize, textAlign: e.style.textAlign, overflowY: e.style.overflowY, overflowX: e.style.overflowX, wordWrap: e.style.wordWrap }); e.addEventListener("autosize:destroy", h), e.addEventListener("autosize:update", u), e.addEventListener("input", a), window.addEventListener("resize", u), e.style.overflowX = "hidden", e.style.wordWrap = "break-word", Y.set(e, { destroy: h, update: u }), u(); } function c(g) { var f, m, d = g.restoreTextAlign, y = d === void 0 ? null : d, A = g.testForHeightReduction, w = A === void 0 || A, E = r.overflowY; if (e.scrollHeight !== 0 && (r.resize === "vertical" ? e.style.resize = "none" : r.resize === "both" && (e.style.resize = "horizontal"), w && (f = function(L) { for (var N = []; L && L.parentNode && L.parentNode instanceof Element; ) L.parentNode.scrollTop && N.push([L.parentNode, L.parentNode.scrollTop]), L = L.parentNode; return function() { return N.forEach(function(D) { var B = D[0], ae = D[1]; B.style.scrollBehavior = "auto", B.scrollTop = ae, B.style.scrollBehavior = null; }); }; }(e), e.style.height = ""), m = r.boxSizing === "content-box" ? e.scrollHeight - (parseFloat(r.paddingTop) + parseFloat(r.paddingBottom)) : e.scrollHeight + parseFloat(r.borderTopWidth) + parseFloat(r.borderBottomWidth), r.maxHeight !== "none" && m > parseFloat(r.maxHeight) ? (r.overflowY === "hidden" && (e.style.overflow = "scroll"), m = parseFloat(r.maxHeight)) : r.overflowY !== "hidden" && (e.style.overflow = "hidden"), e.style.height = m + "px", y && (e.style.textAlign = y), f && f(), n !== m && (e.dispatchEvent(new Event("autosize:resized", { bubbles: !0 })), n = m), E !== r.overflow && !y)) { var O = r.textAlign; r.overflow === "hidden" && (e.style.textAlign = O === "start" ? "end" : "start"), c({ restoreTextAlign: O, testForHeightReduction: !0 }); } } function u() { c({ testForHeightReduction: !0, restoreTextAlign: null }); } }(t); }), o; }).destroy = function(o) { return o && Array.prototype.forEach.call(o.length ? o : [o], Ie), o; }, U.update = function(o) { return o && Array.prototype.forEach.call(o.length ? o : [o], ke), o; }); var Et = U; const be = /([\:\-\_]+(.))/g, Re = /^moz([A-Z])/, De = function(o, s, t, e) { const i = document.createElement(o); return i.className = s || "", e && (i.id = e), t && t.appendChild(i), i; }, st = function(o) { return typeof o == "string" ? document.getElementById(o) : o; }, Se = function(o, s) { const t = o.parentNode; t && t.removeChild(o); }, He = function(o, s, t) { const e = document.createElement(o); return e.style.display = "none", t && (e.id = t), s && s.appendChild(e), e; }, Rt = function(o) { return o.replace(be, (s, t, e, i) => i ? e.toUpperCase() : e).replace(Re, "Moz$1"); }, _ = function() { if (document) return function(o, s, t) { o && s && t && o.addEventListener(s, t, !1); }; }(), F = function() { if (document) return function(o, s, t) { o && s && o.removeEventListener(s, t, !1); }; }(); function Oe(o, s) { if (!o || !s) return !1; if (s.indexOf(" ") !== -1) throw new Error("className should not contain space."); return o.classList ? o.classList.contains(s) : ` ${o.className} `.indexOf(` ${s} `) > -1; } function Ne(o, s) { var t; if (!o || !s) return null; s = Rt(s), s === "float" && (s = "cssFloat"); try { const e = (t = document.defaultView) == null ? void 0 : t.getComputedStyle(o, ""); return o.style[s] || e ? e == null ? void 0 : e[s] : null; } catch { return o.style[s]; } } function Q(o, s, t) { if (!(!o || !s)) if (typeof s == "object") for (const e in s) s.hasOwnProperty(e) && Q(o, e, s[e]); else s = Rt(s), s === "opacity" ? o.style.filter = isNaN(t) ? "" : `alpha(opacity=${t * 100})` : o.style[s] = t; } class b extends Pe { constructor(s, t = {}) { super(s), Object.keys(t).forEach((e) => { this[e] = t[e]; }); } } class We extends nt { // eslint-disable-next-line default-param-last constructor(s = {}, t) { const [ e, i, n, r, a, h, c, u, g, f ] = [ s.id, s.element, s.offset, s.stopEvent, s.positioning, s.insertFirst, s.autoPan, s.autoPanAnimation, s.autoPanMargin, s.className ? s.className : "ol-plot-text-editor" ]; super({ id: e, element: i, stopEvent: r, insertFirst: h, autoPan: c, autoPanAnimation: u, autoPanMargin: g, className: f }), this.parent = t, this.setOffset(n !== void 0 ? n : [0, 0]), this.setPositioning(a !== void 0 ? a : "center-center"), this.mapDragPan = void 0, this.isClick_ = !1, this.dragging_ = !1, this.isFocus_ = !1, this.options_ = s, this._position = s.position && s.position.length > 0 ? s.position : [], this.handleTimer_ = null, this.currentPixel_ = [], this.freehand = !1, mt( [ "handleFocus_", "handleBlur_", "handleClick_", "handleDragStart_", "handleDragEnd_", "handleDragDrag_", "closeCurrentPlotText", "handleResizeMouseDown_", "handleResizeMouseMove_", "handleResizeMouseUp_", "resizeButtonMoveHandler_" ], this ), this.createTextContent(s); } /** * 创建文本框父容器 * @param options */ createTextContent(s) { const t = s.className || "ol-plot-text-editor", e = document.createElement("textarea"); e.className = t, e.style.width = `${s.width}px`, e.style.height = `${s.height}px`, e.style.minHeight = `${s.minHeight}px`, e.setAttribute("id", s.id), e.setAttribute("autofocus", !0), Et(e), _(e, "focus", this.handleFocus_), _(e, "blur", this.handleBlur_), _(e, "click", this.handleClick_), _(e, "mousedown", this.handleDragStart_), _(window, "mouseup", this.handleDragEnd_), this.set("isPlotText", !0), this.setElement(e), this.createCloseButton(s), this.createResizeButton(s), this.setPosition(this._position), this.dispatchEvent( new b("textBoxDrawEnd", { overlay: this, element: e, uuid: s.id }) ); } /** * 获取文本框 * @returns {string} * @private */ getTextAreaFromContent_() { let s = ""; const t = Array.prototype.slice.call(this.element && this.element.children, 0); return t.length > 0 && t.every((e) => e.nodeType === 1 && e.nodeName.toLowerCase() === "textarea" ? (s = e, !1) : !0), s; } /** * 创建关闭按钮 * @param options */ createCloseButton(s) { const t = document.createElement("span"); t.className = "ol-plot-text-editor-close", t.setAttribute("data-id", s.id), F(t, "click", this.closeCurrentPlotText), _(t, "click", this.closeCurrentPlotText), this.element.appendChild(t); } /** * 创建文本框大小调整按钮 * @param options */ createResizeButton(s) { const t = document.createElement("span"); t.className = "ol-plot-text-editor-resize", t.setAttribute("data-id", s.id), F(t, "mousedown", this.handleResizeMouseDown_), F(t, "mousemove", this.handleResizeMouseMove_), _(t, "mousedown", this.handleResizeMouseDown_), _(t, "mousemove", this.handleResizeMouseMove_), this.element.appendChild(t); } /** * 调整大小 * @param event * @private */ resizeButtonMoveHandler_(s) { const t = s.pixel, e = this.getTextAreaFromContent_(); if (t.length < 1 || this.currentPixel_.length < 1 || !e) return; const i = [t[0] - this.currentPixel_[0], t[1] - this.currentPixel_[1]], n = [e.offsetWidth, e.offsetHeight], r = n[0] + i[0] * 2, a = n[1] + i[1] * 2; Q(e, "width", `${r}px`), Q(e, "height", `${a}px`), this.currentPixel_ = t, this.getMap().render(); } /** * 处理移动事件 * @param event * @private */ handleResizeMouseMove_(s) { s.stopImmediatePropagation(); } /** * 处理鼠标按下事件 * @param event * @private */ handleResizeMouseDown_(s) { this.getMap() && (this.currentPixel_ = [s.x, s.y], this.getMap().on("pointermove", this.resizeButtonMoveHandler_), _(this.getMap().getViewport(), "mouseup", this.handleResizeMouseUp_)); } /** * 处理鼠标抬起事件,移除所有事件监听 * @private */ handleResizeMouseUp_() { this.getMap() && (this.getMap().un("pointermove", this.resizeButtonMoveHandler_), F(this.getMap().getViewport(), "mouseup", this.handleResizeMouseUp_), this.currentPixel_ = []); } /** * 处理关闭事件 * @param event */ closeCurrentPlotText(s) { if (this.getMap() && s && Oe(s.target, "ol-plot-text-editor-close")) { const t = s.target.getAttribute("data-id"); if (t) { const e = this.getMap().getOverlayById(t); e && this.getMap().removeOverlay(e); } } } /** * 处理获取焦点事件 * @private */ handleFocus_() { this.isFocus_ = !0, this.parent && this.parent.dispatchEvent( new b("activeTextArea", { overlay: this }) ); } /** * 处理失去焦点事件 * @private */ handleBlur_() { this.isFocus_ = !1, this.parent && this.parent.dispatchEvent( new b("deactivateTextArea", { overlay: this }) ); } /** * 处理拖拽开始 * @private */ handleDragStart_() { this.getMap() && !this.dragging_ && this.isMoveModel() && this.isFocus_ && (this.handleTimer_ = window.setTimeout(() => { window.clearTimeout(this.handleTimer_), this.handleTimer_ = null, this.isClick_ || (this.dragging_ = !0, this.disableMapDragPan(), this.preCursor_ = this.element.style.cursor, _(this.getMap().getViewport(), "mousemove", this.handleDragDrag_), _(this.element, "mouseup", this.handleDragEnd_)); }, 300)); } /** * 处理拖拽 * @param event * @private */ handleDragDrag_(s) { this.dragging_ && (this.element.style.cursor = "move", this._position = this.getMap().getCoordinateFromPixel([s.clientX, s.clientY]), this.setPosition(this._position)); } /** * 处理拖拽 * @private */ handleDragEnd_() { this.isClick_ = !1, window.clearTimeout(this.handleTimer_), this.handleTimer_ = null, this.dragging_ && this.isFocus_ && (this.dragging_ = !1, this.enableMapDragPan(), this.element.style.cursor = this.preCursor_, F(this.getMap().getViewport(), "mousemove", this.handleDragDrag_), F(this.element, "mouseup", this.handleDragEnd_)); } /** * 处理点击事件 * @param event * @private */ handleClick_(s) { s.target === this.element ? this.isClick_ = !0 : this.isClick_ = !1; } /** * 是否处于选择模式 * @returns {boolean} */ isMoveModel() { if (!window) return !1; try { return window.getSelection() ? window.getSelection().getRangeAt(0).collapsed : !1; } catch (s) { console.error("[ol-plot]: PlotTextBox check move error", s); } } /** * 设置样式 * @param style */ setStyle(s = {}) { const t = this.getTextAreaFromContent_(); if (t) for (const e in s) s[e] && Q(t, e, s[e]); } /** * 获取当前样式 * @returns {CSSStyleDeclaration} */ getStyle() { const s = {}, t = this.getTextAreaFromContent_(); if (t) for (const e in Mt) s[e] = Ne(t, e); return s; } /** * set value * @param value */ setValue(s) { const t = this.getTextAreaFromContent_(); t && (t.value = s, s && Et.update(t), this.getMap().render()); } /** * get value * @returns {*} */ getValue() { const s = this.getTextAreaFromContent_(); return s ? s.value : ""; } /** * 获取宽度 * @returns {number} */ getWidth() { const s = this.getTextAreaFromContent_(); return s && s.offsetWidth ? s.offsetWidth : 0; } /** * 获取高度 * @returns {number} */ getHeight() { const s = this.getTextAreaFromContent_(); return s && s.offsetHeight ? s.offsetHeight : 0; } /** * 激活地图的拖拽平移 */ enableMapDragPan() { const s = this.getMap(); s && this.mapDragPan && (s.addInteraction(this.mapDragPan), delete this.mapDragPan); } /** * 禁止地图的拖拽平移 */ disableMapDragPan() { const s = this.getMap(); if (!s) return; s.getInteractions().getArray().every((e) => e instanceof Tt || e.constructor.name.indexOf("DragPan") > -1 ? (this.mapDragPan = e, s.removeInteraction(e), !1) : !0); } /** * set map * @param map */ setMap(s) { super.setMap(s), s && s instanceof M && (this.setStyle(It(Mt, this.options_.style)), this.setValue(this.options_.value)); } finishDrawing() { } } const yt = We; class Be extends ut { constructor(t, e, i) { super([]); l(this, "type"); l(this, "fixPointCount"); l(this, "map"); l(this, "points"); l(this, "freehand"); l(this, "options"); this.type = p.POINT, this.options = i || {}, this.freehand = !1, this.set("params", this.options), this.fixPointCount = 1, e && e.length > 0 ? this.setPoints(e) : t && t.length > 0 && this.setCoordinates(t); } /** * 获取标绘类型 * @returns {*} */ getPlotType() { return this.type; } generate() { const t = this.points[0]; this.setCoordinates(t); } /** * 设置地图对象 * @param map */ setMap(t) { if (t && t instanceof M) this.map = t; else throw new Error("传入的不是地图对象!"); } /** * 获取当前地图对象 * @returns {{}|*} */ getMap() { return this.map; } /** * 判断是否是Plot * @returns {boolean} */ isPlot() { return !0; } /** * 设置坐标点 * @param value */ setPoints(t) { this.points = t || [], this.points.length >= 1 && this.generate(); } /** * 获取坐标点 * @returns {Array.<T>} */ getPoints() { return this.points.slice(0); } /** * 获取点数量 * @returns {Number} */ getPointCount() { return this.points.length; } /** * 更新当前坐标 * @param point * @param index */ updatePoint(t, e) { e >= 0 && e < this.points.length && (this.points[e] = t, this.generate()); } /** * 更新最后一个坐标 * @param point */ updateLastPoint(t) { this.updatePoint(t, this.points.length - 1); } /** * 结束绘制 */ finishDrawing() { } } const Dt = Be; class ze extends ut { constructor(t, e, i) { super([]); l(this, "type"); l(this, "fixPointCount"); l(this, "map"); l(this, "points"); l(this, "freehand"); l(this, "options"); this.type = p.PENNANT, this.options = i || {}, this.freehand = !1, this.fixPointCount = void 0, this.set("params", this.options), e && e.length > 0 ? this.setPoints(e) : t && t.length > 0 && this.setCoordinates(t); } /** * 获取标绘类型 * @returns {*} */ getPlotType() { return this.type; } generate() { this.setCoordinates(this.points); } /** * 设置地图对象 * @param map */ setMap(t) { if (t && t instanceof M) this.map = t; else throw new Error("传入的不是地图对象!"); } /** * 获取当前地图对象 * @returns {{}|*} */ getMap() { return this.map; } /** * 判断是否是Plot * @returns {boolean} */ isPlot() { return !0; } /** * 设置坐标点 * @param value */ setPoints(t) { this.points = t || [], this.points.length >= 1 && this.generate(); } /** * 获取坐标点 * @returns {Array.<T>} */ getPoints() { return this.points.slice(0); } /** * 获取点数量 * @returns {Number} */ getPointCount() { return this.points.length; } /** * 更新当前坐标 * @param point * @param index */ updatePoint(t, e) { e >= 0 && e < this.points.length && (this.points[e] = t, this.generate()); } /** * 更新最后一个坐标 * @param point */ updateLastPoint(t) { this.updatePoint(t, this.points.length - 1); } /** * 结束绘制 */ finishDrawing() { } } const St = ze; class $e extends X { constructor(t, e, i) { super([]); l(this, "type"); l(this, "fixPointCount"); l(this, "map"); l(this, "points"); l(this, "freehand"); this.type = p.POLYLINE, this.freehand = !1, this.set("params", i), e && e.length > 0 ? this.setPoints(e) : t && t.length > 0 && this.setCoordinates(t); } /** * 获取标绘类型 * @returns {*} */ getPlotType() { return this.type; } /** * 执行动作 */ generate() { this.setCoordinates(this.points); } /** * 设置地图对象 * @param map */ setMap(t) { if (t && t instanceof M) this.map = t; else throw new Error("传入的不是地图对象!"); } /** * 获取当前地图对象 * @returns {ol.Map|*} */ getMap() { return this.map; } /** * 判断是否是Plot * @returns {boolean} */ isPlot() { return !0; } /** * 设置坐标点 * @param value */ setPoints(t) { this.points = t || [], this.points.length >= 1 && this.generate(); } /** * 获取坐标点 * @returns {Array.<T>} */ getPoints() { return this.points.slice(0); } /** * 获取点数量 * @returns {Number} */ getPointCount() { return this.points.length; } /** * 更新当前坐标 * @param point * @param index */ updatePoint(t, e) { e >= 0 && e < this.points.length && (this.points[e] = t, this.generate()); } /** * 更新最后一个坐标 * @param point */ updateLastPoint(t) { this.updatePoint(t, this.points.length - 1); } /** * 结束绘制 */ finishDrawing() { } } const Ht = $e; class Ge extends X { constructor(t, e, i) { super([]); l(this, "type"); l(this, "fixPointCount"); l(this, "freehand"); l(this, "map"); l(this, "points"); this.type = p.ARC, this.fixPointCount = 3, this.set("params", i), e && e.length > 0 ? this.setPoints(e) : t && t.length > 0 && this.setCoordinates(t); } /** * 获取标绘类型 * @returns {*} */ getPlotType() { return this.type; } /** * 执行动作 */ generate() { const t = this.getPointCount(); if (!(t < 2)) if (t === 2) this.setCoordinates(this.points); else { let [e, i, n, r, a] = [this.points[0], this.points[1], this.points[2], 0, 0]; const h = Ft(e, i, n), c = v(e, h), u = R(e, h), g = R(i, h); $(e, i, n) ? (r = g, a = u) : (r = u, a = g), this.setCoordinates(dt(h, c, r, a)); } } /** * 设置地图对象 * @param map */ setMap(t) { if (t && t instanceof M) this.map = t; else throw new Error("传入的不是地图对象!"); } /** * 获取当前地图对象 * @returns {ol.Map|*} */ getMap() { return this.map; } /** * 判断是否是Plot * @returns {boolean} */ isPlot() { return !0; } /** * 设置坐标点 * @param value */ setPoints(t) { this.points = t || [], this.points.length >= 1 && this.generate(); } /** * 获取坐标点 * @returns {Array.<T>} */ getPoints() { return this.points.slice(0); } /** * 获取点数量 * @returns {Number} */ getPointCount() { return this.points.length; } /** * 更新当前坐标 * @param point * @param index */ updatePoint(t, e) { e >= 0 && e < this.points.length && (this.points[e] = t, this.generate()); } /** * 更新最后一个坐标 * @param point */ updateLastPoint(t) { this.updatePoint(t, this.points.length - 1); } /** * 结束绘制 */ finishDrawing() { } } const Ot = Ge; class Ue extends x { constructor(t, e, i) { super([]); l(this, "type"); l(this, "fixPointCount"); l(this, "map"); l(this, "points"); l(this, "freehand"); this.type = p.CIRCLE, this.fixPointCount = 2, this.set("params", i), e && e.length > 0 ? this.setPoints(e) : t && t.length > 0 && this.setCoordinates(t); } /** * 获取标绘类型 * @returns {*} */ getPlotType() { return this.type; } generate() { if (this.getPointCount() < 2) return !1; const e = this.points[0], i = v(e, this.points[1]); this.setCoordinates([this.generatePoints(e, i)]); } /** * 对圆边线进行插值 * @param center * @param radius * @returns {null} */ generatePoints(t, e) { let [i, n, r] = [0, 0, 0]; const a = []; for (let h = 0; h <= 100; h++) r = Math.PI * 2 * h / 100, i = t[0] + e * Math.cos(r), n = t[1] + e * Math.sin(r), a.push([i, n]); return a; } /** * 设置地图对象 * @param map */ setMap(t) { if (t && t instanceof M) this.map = t; else throw new Error("传入的不是地图对象!"); } /** * 获取当前地图对象 * @returns {{}|*} */ getMap() { return this.map; } /** * 判断是否是Plot * @returns {boolean} */ isPlot() { return !0; } /** * 设置坐标点 * @param value */ setPoints(t) { this.points = t || [], this.points.length >= 1 && this.generate(); } /** * 获取坐标点 * @returns {Array.<T>} */ getPoints() { return this.points.slice(0); } /** * 获取点数量 * @returns {Number} */ getPointCount() { return this.points.length; } /** * 更新当前坐标 * @param point * @param index */ updatePoint(t, e) { e >= 0 && e < this.points.length && (this.points[e] = t, this.generate()); } /** * 更新最后一个坐标 * @param point */ updateLastPoint(t) { this.updatePoint(t, this.points.length - 1); } /** * 结束绘制 */ finishDrawing() { } } const Nt = Ue; class Ve extends X { constructor(t, e, i) { super([]); l(this, "type"); l(this, "fixPointCount"); l(this, "map"); l(this, "points"); l(this, "freehand"); l(this, "t"); this.type = p.CURVE, this.t = 0.3, this.set("params", i), e && e.length > 0 ? this.setPoints(e) : t && t.length > 0 && this.setCoordinates(t); } /** * 获取标绘类型 * @returns {*} */ getPlotType() { return this.type; } /** * 执行动作 */ generate() { const t = this.getPointCount(); if (t < 2) return !1; if (t === 2) this.setCoordinates(this.points); else { const e = Te(this.t, this.points); this.setCoordinates(e); } } /** * 设置地图对象 * @param map */ setMap(t) { if (t && t instanceof M) this.map = t; else throw new Error("传入的不是地图对象!"); } /** * 获取当前地图对象 * @returns {ol.Map|*} */ getMap() { return this.map; } /** * 判断是否是Plot * @returns {boolean} */ isPlot() { return !0; } /** * 设置坐标点 * @param value */ setPoints(t) { this.points = t || [], this.points.length >= 1 && this.generate(); } /** * 获取坐标点 * @returns {Array.<T>} */ getPoints() { return this.points.slice(0); } /** * 获取点数量 * @returns {Number} */ getPointCount() { return this.points.length; } /** * 更新当前坐标 * @param point * @param index */ updatePoint(t, e) { e >= 0 && e < this.points.length && (this.points[e] = t, this.generate()); } /** * 更新最后一个坐标 * @param point */ updateLastPoint(t) { this.updatePoint(t, this.points.length - 1); } /** * 结束绘制 */ finishDrawing() { } } const Wt = Ve; class Ye extends X { constructor(t, e, i) { super([]); l(this, "type"); l(this, "fixPointCount"); l(this, "map"); l(this, "points"); l(this, "freehand"); this.type = p.FREEHANDLINE, this.freehand = !0, this.set("params", i), e && e.length > 0 ? this.setPoints(e) : t && t.length > 0 && this.setCoordinates(t); } /** * 获取标绘类型 * @returns {*} */ getPlotType() { return this.type; } /** * 执行动作 */ generate() { this.setCoordinates(this.points); } /** * 设置地图对象 * @param map */ setMap(t) { if (t && t instanceof M) this.map = t; else throw new Error("传入的不是地图对象!"); } /** * 获取当前地图对象 * @returns {ol.Map|*} */ getMap() { return this.map; } /** * 判断是否是Plot * @returns {boolean} */ isPlot() { return !0; } /** * 设置坐标点 * @param value */ setPoints(t) { this.points = t || [], this.points.length >= 1 && this.generate(); } /** * 获取坐标点 * @returns {Array.<T>} */ getPoints() { return this.points.slice(0); } /** * 获取点数量 * @returns {Number} */ getPointCount() { return this.points.length; } /** * 更新当前坐标 * @param point * @param index */ updatePoint(t, e) { e >= 0 && e < this.points.length && (this.points[e] = t, this.generate()); } /** * 更新最后一个坐标 * @param point */ updateLastPoint(t) { this.updatePoint(t, this.points.length - 1); } /** * 结束绘制 */ finishDrawing() { } } const Bt = Ye; class Xe extends x { constructor(t, e, i) { super([]); l(this, "type"); l(this, "fixPointCount"); l(this, "map"); l(this, "points"); l(this, "freehand"); l(this, "isFill"); this.type = p.RECTANGLE, this.fixPointCount = 2, this.set("params", i), this.isFill = i.isFill === !1 ? i.isFill : !0, e && e.length > 0 ? this.setPoints(e) : t && t.length > 0 && this.setCoordinates(t); } /** * 获取标绘类型 * @returns {*} */ getPlotType() { return this.type; } /** * 执行动作 */ generate() { if (this.points.length === 2) { let t; if (this.isFill) { const e = we(this.points); t = ye(e).getCoordinates(); } else { const e = this.points[0], i = this.points[1]; t = [e, [e[0], i[1]], i, [i[0], e[1]], e]; } this.setCoordinates(t); } } /** * 设置地图对象 * @param map */ setMap(t) { if (t && t instanceof M) this.map = t; else throw new Error("传入的不是地图对象!"); } /** * 获取当前地图对象 * @returns {Map|*} */ getMap() { return this.map; } /** * 判断是否是Plot * @returns {boolean} */ isPlot() { return !0; } /** * 设置坐标点 * @param value */ setPoints(t) { this.points = t || [], this.points.length >= 1 && this.generate(); } /** * 获取坐标点 * @returns {Array.<T>} */ getPoints() { return this.points.slice(0); } /** * 获取点数量 * @returns {Number} */ getPointCount() { return this.points.length; } /** * 更新当前坐标 * @param point * @param index */ updatePoint(t, e) { e >= 0 && e < this.points.length && (this.points[e] = t, this.generate()); } /** * 更新最后一个坐标 * @param point */ updateLastPoint(t) { this.updatePoint(t, this.points.length - 1); } /** * 结束绘制 */ finishDrawing() { } } const zt = Xe; class qe extends x { constructor(t, e, i) { super([]); l(this, "type"); l(this, "fixPointCount"); l(this, "map"); l(this, "points"); l(this, "freehand"); this.type = p.ELLIPSE, this.fixPointCount = 2, this.set("params", i), e && e.length > 0 ? this.setPoints(e) : t && t.length > 0 && this.setCoordinates(t); } /** * 获取标绘类型 * @returns {*} */ getPlotType() { return this.type; } generate() { if (this.getPointCount() < 2) return !1; const [t, e] = [this.points[0], this.points[1]], i = T(t, e), n = Math.abs((t[0] - e[0]) / 2), r = Math.abs((t[1] - e[1]) / 2), a = this.generatePoints(i, n, r); this.setCoordinates([a]); } /** * 对圆边线进行插值 * @param center * @param majorRadius * @param minorRadius * @returns {*} */ generatePoints(t, e, i) { let [n, r, a] = [0, 0, 0]; const h = []; for (let c = 0; c <= S; c++) a = Math.PI * 2 * c / S, n = t[0] + e * Math.cos(a), r = t[1] + i * Math.sin(a), h.push([n, r]); return h; } /** * 设置地图对象 * @param map */ setMap(t) { if (t && t instanceof M) this.map = t; else throw new Error("传入的不是地图对象!"); } /** * 获取当前地图对象 * @returns {{}|*} */ getMap() { return this.map; } /** * 判断是否是Plot * @returns {boolean} */ isPlot() { return !0; } /** * 设置坐标点 * @param value */ setPoints(t) { this.points = t || [], this.points.length >= 1 && this.generate(); } /** * 获取坐标点 * @returns {Array.<T>} */ getPoints() { return this.points.slice(0); } /** * 获取点数量 * @returns {Number} */ getPointCount() { return this.points.length; } /** * 更新当前坐标 * @param point * @param index */ updatePoint(t, e) { e >= 0 && e < this.points.length && (this.points[e] = t, this.generate()); } /** * 更新最后一个坐标 * @param point */ updateLastPoint(t) { this.updatePoint(t, this.points.length - 1); } /** * 结束绘制 */ finishDrawing() { } } const $t = qe; class je extends x { constructor(t, e, i) { super([]); l(this, "type"); l(this, "fixPointCount"); l(this, "map"); l(this, "points"); l(this, "freehand"); this.type = p.LUNE, this.fixPointCount = 3, this.set("params", i), e && e.length > 0 ? this.setPoints(e) : t && t.length > 0 && this.setCoordinates(t); } /** * 获取标绘类型 * @returns {*} */ getPlotType() { return this.type; } /** * 执行动作 */ generate() { if (this.getPointCount() < 2) return !1; let t = this.getPoints(); if (this.getPointCount() === 2) { const f = T(t[0], t[1]), m = v(t[0], f), d = P(t[0], f, C, m); t.push(d); } let [e, i, n, r, a] = [t[0], t[1], t[2], 0, 0]; const h = Ft(e, i, n), c = v(e, h), u = R(e, h), g = R(i, h); $(e, i, n) ? (r = g, a = u) : (r = u, a = g), t = dt(h, c, r, a), t.push(t[0]), this.setCoordinates([t]); } /** * 设置地图对象 * @param map */ setMap(t) { if (t && t instanceof M) this.map = t; else throw new Error("传入的不是地图对象!"); } /** * 获取当前地图对象 * @returns {Map|*} */ getMap() { return this.map; } /** * 判断是否是Plot * @returns {boolean} */ isPlot() { return !0; } /** * 设置坐标点 * @param value */ setPoints(t) { this.points = t || [], this.points.length >= 1 && this.generate(); } /** * 获取坐标点 * @returns {Array.<T>} */ getPoints() { return this.points.slice(0); } /** * 获取点数量 * @returns {Number} */ getPointCount() { return this.points.length; } /** * 更新当前坐标 * @param point * @param index */ updatePoint(t, e) { e >= 0 && e < this.points.length && (this.points[e] = t, this.generate()); } /** * 更新最后一个坐标 * @param point */ updateLastPoint(t) { this.updatePoint(t, this.points.length - 1); } /** * 结束绘制 */ finishDrawing() { } } const Gt = je; class Ze extends x { constructor(t, e, i) { super([]); l(this, "type"); l(this, "fixPointCount"); l(this, "map"); l(this, "points"); l(this, "freehand"); this.type = p.SECTOR, this.fixPointCount = 3, this.set("params", i), e && e.length > 0 ? this.setPoints(e) : t && t.length > 0 && this.setCoordinates(t); } /** * 获取标绘类型 * @returns {*} */ getPlotType() { return this.type; } /** * 执行动作 */ generate() { const t = this.getPointCount(); if (t < 2) return !1; if (t === 2) this.setCoordinates([this.points]); else { const e = this.getPoints(), [i, n, r] = [e[0], e[1], e[2]], a = v(n, i), h = R(n, i), c = R(r, i), u = dt(i, a, h, c); u.push(i, u[0]), this.setCoordinates([u]); } } /** * 设置地图对象 * @param map */ setMap(t) { if (t && t instanceof M) this.map = t; else throw new Error("传入的不是地图对象!"); } /** * 获取当前地图对象 * @returns {ol.Map|*} */ getMap() { return this.map; } /** * 判断是否是Plot * @returns {boolean} */ isPlot() { return !0; } /** * 设置坐标点 * @param value */ setPoints(t) { this.points = t || [], this.points.length >= 1 && this.generate(); } /** * 获取坐标点 * @returns {Array.<T>} */ getPoints() { return this.points.slice(0); } /** * 获取点数量 * @returns {Number} */ getPointCount() { return this.points.length; } /** * 更新当前坐标 * @param point * @param index */ updatePoint(t, e) { e >= 0 && e < this.points.length && (this.points[e] = t, this.generate()); } /** * 更新最后一个坐标 * @param point */ updateLastPoint(t) { this.updatePoint(t, this.points.length - 1); } /** * 结束绘制 */ finishDrawing() { } } const Ut = Ze; class Qe extends x { constructor(t, e, i) { super([]); l(this, "type"); l(this, "fixPointCount"); l(this, "map"); l(this, "points"); l(this, "freehand"); l(this, "t"); this.type = p.CLOSED_CURVE, this.t = 0.3, this.set("params", i), e && e.length > 0 ? this.setPoints(e) : t && t.length > 0 && this.setCoordinates(t); } /** * 获取标绘类型 * @returns {*} */ getPlotType() { return this.type; } /** * 执行动作 */ generate() { const t = this.getPointCount(); if (t < 2) return !1; if (t === 2) this.setCoordinates([this.points]); else { const e = this.getPoints(); e.push(e[0], e[1]); let i = []; const n = []; for (let a = 0; a < e.length - 2; a++) { const h = q(this.t, e[a], e[a + 1], e[a + 2]); i = i.concat(h); } const r = i.length; i = [i[r - 1]].concat(i.slice(0, r - 1)); for (let a = 0; a < e.length - 2; a++) { const h = e[a], c = e[a + 1]; n.push(h); for (let u = 0; u <= S; u++) { const g = pt( u / S, h, i[a * 2], i[a * 2 + 1], c ); n.push(g); } n.push(c); } this.setCoordinates([n]); } } /** * 设置地图对象 * @param map */ setMap(t) { if (t && t instanceof M) this.map = t; else throw new Error("传入的不是地图对象!"); } /** * 获取当前地图对象 * @returns {Map|*} */ getMap() { return this.map; } /** * 判断是否是Plot * @returns {boolean} */ isPlot() { return !0; } /** * 设置坐标点 * @param value */ setPoints(t) { this.points = t || [], this.points.length >= 1 && this.generate(); } /** * 获取坐标点 * @returns {Array.<T>} */ getPoints() { return this.points.slice(0); } /** * 获取点数量 * @returns {Number} */ getPointCount() { return this.points.length; } /** * 更新当前坐标 * @param point * @param index */ updatePoint(t, e) { e >= 0 && e < this.points.length && (this.points[e] = t, this.generate()); } /** * 更新最后一个坐标 * @param point */ updateLastPoint(t) { this.updatePoint(t, this.points.length - 1); } /** * 结束绘制 */ finishDrawing() { } } const Vt = Qe; class Ke extends x { constructor(t, e, i) { super([]); l(this, "type"); l(this, "fixPointCount"); l(this, "map"); l(this, "points"); l(this, "freehand"); this.type = p.POLYGON, this.set("params", i), e && e.length > 0 ? this.setPoints(e) : t && t.length > 0 && this.setCoordinates(t); } /** * 获取标绘类型 * @returns {*} */ getPlotType() { return this.type; } /** * 执行动作 */ generate() { if (this.getPointCount() < 2) return !1; this.setCoordinates([this.points]); } /** * 设置地图对象 * @param map */ setMap(t) { if (t && t instanceof M) this.map = t; else throw new Error("传入的不是地图对象!"); } /** * 获取当前地图对象 * @returns {Map|*} */ getMap() { return this.map; } /** * 判断是否是Plot * @returns {boolean} */ isPlot() { return !0; } /** * 设置坐标点 * @param value */ setPoints(t) { this.points = t || [], this.points.length >= 1 && this.generate(); } /** * 获取坐标点 * @returns {Array.<T>} */ getPoints() { return this.points.slice(0); } /** * 获取点数量 * @returns {Number} */ getPointCount() { return this.points.length; } /** * 更新当前坐标 * @param point * @param index */ updatePoint(t, e) { e >= 0 && e < this.points.length && (this.points[e] = t, this.generate()); } /** * 更新最后一个坐标 * @param point */ updateLastPoint(t) { this.updatePoint(t, this.points.length - 1); } /** * 结束绘制 */ finishDrawing() { } } const Yt = Ke; class Je extends x { constructor(t, e, i) { super([]); l(this, "type"); l(this, "fixPointCount"); l(this, "map"); l(this, "points"); l(this, "freehand"); this.type = p.FREE_POLYGON, this.freehand = !0, this.set("params", i), e && e.length > 0 ? this.setPoints(e) : t && t.length > 0 && this.setCoordinates(t); } /** * 获取标绘类型 * @returns {*} */ getPlotType() { return this.type; } /** * 执行动作 */ generate() { this.setCoordinates([this.points]); } /** * 设置地图对象 * @param map */ setMap(t) { if (t && t instanceof M) this.map = t; else throw new Error("传入的不是地图对象!"); } /** * 获取当前地图对象 * @returns {Map|*} */ getMap() { return this.map; } /** * 判断是否是Plot * @returns {boolean} */ isPlot() { return !0; } /** * 设置坐标点 * @param value */ setPoints(t) { this.points = t || [], this.points.length >= 1 && this.generate(); } /** * 获取坐标点 * @returns {Array.<T>} */ getPoints() { return this.points.slice(0); } /** * 获取点数量 * @returns {Number} */ getPointCount() { return this.points.length; } /** * 更新当前坐标 * @param point * @param index */ updatePoint(t, e) { e >= 0 && e < this.points.length && (this.points[e] = t, this.generate()); } /** * 更新最后一个坐标 * @param point */ updateLastPoint(t) { this.updatePoint(t, this.points.length - 1); } /** * 结束绘制 */ finishDrawing() { } } const Xt = Je; class ts extends x { constructor(t, e, i) { super([]); l(this, "type"); l(this, "fixPointCount"); l(this, "map"); l(this, "points"); l(this, "freehand"); l(this, "headWidthFactor"); l(this, "headHeightFactor"); l(this, "neckWidthFactor"); l(this, "neckHeightFactor"); l(this, "tailWidthFactor"); l(this, "headTailFactor"); l(this, "swallowTailFactor"); l(this, "swallowTailPnt"); this.type = p.ATTACK_ARROW, this.headHeightFactor = 0.18, this.headWidthFactor = 0.3, this.neckHeightFactor = 0.85, this.neckWidthFactor = 0.15, this.headTailFactor = 0.8, this.set("params", i), e && e.length > 0 ? this.setPoints(e) : t && t.length > 0 && this.setCoordinates(t); } /** * 获取标绘类型 * @returns {*} */ getPlotType() { return this.type; } /** * 执行动作 */ generate() { try { const t = this.getPointCount(); if (t < 2) return !1; if (t === 2) this.setCoordinates([this.points]); else { const e = this.getPoints(); let [i, n] = [e[0], e[1]]; $(e[0], e[1], e[2]) && (i = e[1], n = e[0]); const a = [T(i, n)].concat(e.slice(2)), h = this.getArrowHeadPoints(a, i, n); if (h && h.length > 4) { const [c,