UNPKG

gisviewer-vue3-arcgis

Version:

在应用中引入私服的包, 项目根目录下 新建文件 .npmrc 在 .npmrc 中对包源进行配置:

152 lines (151 loc) 3.87 kB
import S from "ol/style/Fill"; import f from "ol/style/Stroke"; import a from "ol/style/Style"; import g from "ol/style/Text"; const c = /* @__PURE__ */ new Map(); let d = null; function x(e, n) { return e ? Array.isArray(e) ? e.map((i) => { if (i.type === "text" && i.field) { const r = (n == null ? void 0 : n[i.field]) ?? ""; return JSON.stringify({ ...i, __textContent__: r }); } return JSON.stringify(i); }).join("|") : JSON.stringify(e) : "__default__"; } function u() { return d || (d = new a({ stroke: new f({ color: "#2563eb", width: 2 }) })), d; } function p(e) { return new a({ stroke: new f({ color: e.color ?? "#2563eb", width: e.width ?? 2, lineCap: e.lineCap ?? "round", lineJoin: e.lineJoin ?? "round", lineDash: e.lineDash, lineDashOffset: e.lineDashOffset ?? 0 }) }); } function s(e) { const n = new a({ stroke: new f({ color: e.borderColor ?? "#000000", width: (e.width ?? 2) + (e.borderWidth ?? 2) * 2, lineCap: e.lineCap ?? "round", lineJoin: e.lineJoin ?? "round", lineDash: e.lineDash, lineDashOffset: e.lineDashOffset ?? 0 }) }), t = new a({ stroke: new f({ color: e.color ?? "#2563eb", width: e.width ?? 2, lineCap: e.lineCap ?? "round", lineJoin: e.lineJoin ?? "round", lineDash: e.lineDash, lineDashOffset: e.lineDashOffset ?? 0 }) }); return [n, t]; } function D(e, n) { const t = n ? n * 2 : 10; switch (e) { case "solid": return; case "dash": return [t * 4, t * 2]; case "dot": return [t, t * 2]; case "dash-dot": return [t * 4, t * 2, t, t * 2]; case "long-dash": return [t * 6, t * 3]; case "long-dash-dot": return [t * 6, t * 2, t, t * 2]; case "long-dash-dot-dot": return [t * 6, t * 2, t, t * 2, t, t * 2]; case "short-dash": return [t * 2, t]; case "short-dot": return [t, t]; case "short-dash-dot": return [t * 2, t, t, t]; case "short-dash-dot-dot": return [t * 2, t, t, t, t, t]; case "none": return [0, 1]; default: return; } } function w(e) { const n = e.width ?? 2, t = D(e.style ?? "solid", n); return new a({ stroke: new f({ color: e.color ?? [0, 0, 0, 1], width: n, lineCap: e.cap ?? "round", lineJoin: e.join ?? "round", lineDash: t, lineDashOffset: 0 }) }); } function C(e, n) { const t = new g({ text: String(n), font: e.font ?? "14px Arial Unicode MS", fill: new S({ color: e.fillColor ?? [0, 0, 0] }), stroke: new f({ color: e.strokeColor ?? [255, 255, 255], width: e.strokeWidth ?? 3 }), offsetX: e.offsetX ?? 0, offsetY: e.offsetY ?? 0, textAlign: e.textAlign ?? "center", textBaseline: e.textBaseline ?? "middle", placement: e.placement ?? "point", overflow: e.overflow ?? !1, maxAngle: e.maxAngle ?? Math.PI / 4 }); return new a({ text: t }); } function _(e, n) { if (!e) return u(); const t = x(e, n), i = c.get(t); if (i) return i; let r; if (Array.isArray(e) && e.length > 0) { const l = []; if (e.forEach((o) => { if (o.type === "line") l.push(p(o)); else if (o.type === "simple-line") l.push(w(o)); else if (o.type === "bordered") l.push(...s(o)); else if (o.type === "text" && o.field) { const h = (n == null ? void 0 : n[o.field]) ?? ""; h && l.push(C(o, h)); } }), l.length > 0) return r = l, c.set(t, r), r; } return e && e.type === "bordered" ? (r = s(e), c.set(t, r), r) : e && e.type === "simple-line" ? (r = w(e), c.set(t, r), r) : e ? (r = p(e), c.set(t, r), r) : u(); } export { D as getLineDashByStyle, _ as getLineStyle };