@eox/drawtools 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # Draw tools
2
+
3
+ ## Usage
4
+
5
+ ```
6
+ npm install @eox/drawtools
7
+ ```
8
+
9
+ ```
10
+ import "@eox/drawtools"
11
+
12
+ <eox-drawtools></eox-drawtools>
13
+ ```
14
+
15
+ // TODO: add documentation
16
+
17
+ ## Contribute
18
+
19
+ ```
20
+ npm watch
21
+ (on root) npm run cypress
22
+ (on root) npm run format
23
+
24
+ npm version <new version>
25
+ npm run build
26
+ npm publish (requires OTP)
27
+ ```
@@ -0,0 +1,720 @@
1
+ var _t = Object.defineProperty;
2
+ var $t = (r, t, e) => t in r ? _t(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var u = (r, t, e) => ($t(r, typeof t != "symbol" ? t + "" : t, e), e);
4
+ /**
5
+ * @license
6
+ * Copyright 2019 Google LLC
7
+ * SPDX-License-Identifier: BSD-3-Clause
8
+ */
9
+ const T = window, G = T.ShadowRoot && (T.ShadyCSS === void 0 || T.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, ht = Symbol(), Q = /* @__PURE__ */ new WeakMap();
10
+ let vt = class {
11
+ constructor(t, e, i) {
12
+ if (this._$cssResult$ = !0, i !== ht)
13
+ throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
14
+ this.cssText = t, this.t = e;
15
+ }
16
+ get styleSheet() {
17
+ let t = this.o;
18
+ const e = this.t;
19
+ if (G && t === void 0) {
20
+ const i = e !== void 0 && e.length === 1;
21
+ i && (t = Q.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), i && Q.set(e, t));
22
+ }
23
+ return t;
24
+ }
25
+ toString() {
26
+ return this.cssText;
27
+ }
28
+ };
29
+ const yt = (r) => new vt(typeof r == "string" ? r : r + "", void 0, ht), ft = (r, t) => {
30
+ G ? r.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet) : t.forEach((e) => {
31
+ const i = document.createElement("style"), s = T.litNonce;
32
+ s !== void 0 && i.setAttribute("nonce", s), i.textContent = e.cssText, r.appendChild(i);
33
+ });
34
+ }, X = G ? (r) => r : (r) => r instanceof CSSStyleSheet ? ((t) => {
35
+ let e = "";
36
+ for (const i of t.cssRules)
37
+ e += i.cssText;
38
+ return yt(e);
39
+ })(r) : r;
40
+ /**
41
+ * @license
42
+ * Copyright 2017 Google LLC
43
+ * SPDX-License-Identifier: BSD-3-Clause
44
+ */
45
+ var j;
46
+ const I = window, Y = I.trustedTypes, gt = Y ? Y.emptyScript : "", tt = I.reactiveElementPolyfillSupport, K = { toAttribute(r, t) {
47
+ switch (t) {
48
+ case Boolean:
49
+ r = r ? gt : null;
50
+ break;
51
+ case Object:
52
+ case Array:
53
+ r = r == null ? r : JSON.stringify(r);
54
+ }
55
+ return r;
56
+ }, fromAttribute(r, t) {
57
+ let e = r;
58
+ switch (t) {
59
+ case Boolean:
60
+ e = r !== null;
61
+ break;
62
+ case Number:
63
+ e = r === null ? null : Number(r);
64
+ break;
65
+ case Object:
66
+ case Array:
67
+ try {
68
+ e = JSON.parse(r);
69
+ } catch {
70
+ e = null;
71
+ }
72
+ }
73
+ return e;
74
+ } }, dt = (r, t) => t !== r && (t == t || r == r), z = { attribute: !0, type: String, converter: K, reflect: !1, hasChanged: dt }, J = "finalized";
75
+ let E = class extends HTMLElement {
76
+ constructor() {
77
+ super(), this._$Ei = /* @__PURE__ */ new Map(), this.isUpdatePending = !1, this.hasUpdated = !1, this._$El = null, this.u();
78
+ }
79
+ static addInitializer(t) {
80
+ var e;
81
+ this.finalize(), ((e = this.h) !== null && e !== void 0 ? e : this.h = []).push(t);
82
+ }
83
+ static get observedAttributes() {
84
+ this.finalize();
85
+ const t = [];
86
+ return this.elementProperties.forEach((e, i) => {
87
+ const s = this._$Ep(i, e);
88
+ s !== void 0 && (this._$Ev.set(s, i), t.push(s));
89
+ }), t;
90
+ }
91
+ static createProperty(t, e = z) {
92
+ if (e.state && (e.attribute = !1), this.finalize(), this.elementProperties.set(t, e), !e.noAccessor && !this.prototype.hasOwnProperty(t)) {
93
+ const i = typeof t == "symbol" ? Symbol() : "__" + t, s = this.getPropertyDescriptor(t, i, e);
94
+ s !== void 0 && Object.defineProperty(this.prototype, t, s);
95
+ }
96
+ }
97
+ static getPropertyDescriptor(t, e, i) {
98
+ return { get() {
99
+ return this[e];
100
+ }, set(s) {
101
+ const n = this[t];
102
+ this[e] = s, this.requestUpdate(t, n, i);
103
+ }, configurable: !0, enumerable: !0 };
104
+ }
105
+ static getPropertyOptions(t) {
106
+ return this.elementProperties.get(t) || z;
107
+ }
108
+ static finalize() {
109
+ if (this.hasOwnProperty(J))
110
+ return !1;
111
+ this[J] = !0;
112
+ const t = Object.getPrototypeOf(this);
113
+ if (t.finalize(), t.h !== void 0 && (this.h = [...t.h]), this.elementProperties = new Map(t.elementProperties), this._$Ev = /* @__PURE__ */ new Map(), this.hasOwnProperty("properties")) {
114
+ const e = this.properties, i = [...Object.getOwnPropertyNames(e), ...Object.getOwnPropertySymbols(e)];
115
+ for (const s of i)
116
+ this.createProperty(s, e[s]);
117
+ }
118
+ return this.elementStyles = this.finalizeStyles(this.styles), !0;
119
+ }
120
+ static finalizeStyles(t) {
121
+ const e = [];
122
+ if (Array.isArray(t)) {
123
+ const i = new Set(t.flat(1 / 0).reverse());
124
+ for (const s of i)
125
+ e.unshift(X(s));
126
+ } else
127
+ t !== void 0 && e.push(X(t));
128
+ return e;
129
+ }
130
+ static _$Ep(t, e) {
131
+ const i = e.attribute;
132
+ return i === !1 ? void 0 : typeof i == "string" ? i : typeof t == "string" ? t.toLowerCase() : void 0;
133
+ }
134
+ u() {
135
+ var t;
136
+ this._$E_ = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$Eg(), this.requestUpdate(), (t = this.constructor.h) === null || t === void 0 || t.forEach((e) => e(this));
137
+ }
138
+ addController(t) {
139
+ var e, i;
140
+ ((e = this._$ES) !== null && e !== void 0 ? e : this._$ES = []).push(t), this.renderRoot !== void 0 && this.isConnected && ((i = t.hostConnected) === null || i === void 0 || i.call(t));
141
+ }
142
+ removeController(t) {
143
+ var e;
144
+ (e = this._$ES) === null || e === void 0 || e.splice(this._$ES.indexOf(t) >>> 0, 1);
145
+ }
146
+ _$Eg() {
147
+ this.constructor.elementProperties.forEach((t, e) => {
148
+ this.hasOwnProperty(e) && (this._$Ei.set(e, this[e]), delete this[e]);
149
+ });
150
+ }
151
+ createRenderRoot() {
152
+ var t;
153
+ const e = (t = this.shadowRoot) !== null && t !== void 0 ? t : this.attachShadow(this.constructor.shadowRootOptions);
154
+ return ft(e, this.constructor.elementStyles), e;
155
+ }
156
+ connectedCallback() {
157
+ var t;
158
+ this.renderRoot === void 0 && (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (t = this._$ES) === null || t === void 0 || t.forEach((e) => {
159
+ var i;
160
+ return (i = e.hostConnected) === null || i === void 0 ? void 0 : i.call(e);
161
+ });
162
+ }
163
+ enableUpdating(t) {
164
+ }
165
+ disconnectedCallback() {
166
+ var t;
167
+ (t = this._$ES) === null || t === void 0 || t.forEach((e) => {
168
+ var i;
169
+ return (i = e.hostDisconnected) === null || i === void 0 ? void 0 : i.call(e);
170
+ });
171
+ }
172
+ attributeChangedCallback(t, e, i) {
173
+ this._$AK(t, i);
174
+ }
175
+ _$EO(t, e, i = z) {
176
+ var s;
177
+ const n = this.constructor._$Ep(t, i);
178
+ if (n !== void 0 && i.reflect === !0) {
179
+ const o = (((s = i.converter) === null || s === void 0 ? void 0 : s.toAttribute) !== void 0 ? i.converter : K).toAttribute(e, i.type);
180
+ this._$El = t, o == null ? this.removeAttribute(n) : this.setAttribute(n, o), this._$El = null;
181
+ }
182
+ }
183
+ _$AK(t, e) {
184
+ var i;
185
+ const s = this.constructor, n = s._$Ev.get(t);
186
+ if (n !== void 0 && this._$El !== n) {
187
+ const o = s.getPropertyOptions(n), d = typeof o.converter == "function" ? { fromAttribute: o.converter } : ((i = o.converter) === null || i === void 0 ? void 0 : i.fromAttribute) !== void 0 ? o.converter : K;
188
+ this._$El = n, this[n] = d.fromAttribute(e, o.type), this._$El = null;
189
+ }
190
+ }
191
+ requestUpdate(t, e, i) {
192
+ let s = !0;
193
+ t !== void 0 && (((i = i || this.constructor.getPropertyOptions(t)).hasChanged || dt)(this[t], e) ? (this._$AL.has(t) || this._$AL.set(t, e), i.reflect === !0 && this._$El !== t && (this._$EC === void 0 && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t, i))) : s = !1), !this.isUpdatePending && s && (this._$E_ = this._$Ej());
194
+ }
195
+ async _$Ej() {
196
+ this.isUpdatePending = !0;
197
+ try {
198
+ await this._$E_;
199
+ } catch (e) {
200
+ Promise.reject(e);
201
+ }
202
+ const t = this.scheduleUpdate();
203
+ return t != null && await t, !this.isUpdatePending;
204
+ }
205
+ scheduleUpdate() {
206
+ return this.performUpdate();
207
+ }
208
+ performUpdate() {
209
+ var t;
210
+ if (!this.isUpdatePending)
211
+ return;
212
+ this.hasUpdated, this._$Ei && (this._$Ei.forEach((s, n) => this[n] = s), this._$Ei = void 0);
213
+ let e = !1;
214
+ const i = this._$AL;
215
+ try {
216
+ e = this.shouldUpdate(i), e ? (this.willUpdate(i), (t = this._$ES) === null || t === void 0 || t.forEach((s) => {
217
+ var n;
218
+ return (n = s.hostUpdate) === null || n === void 0 ? void 0 : n.call(s);
219
+ }), this.update(i)) : this._$Ek();
220
+ } catch (s) {
221
+ throw e = !1, this._$Ek(), s;
222
+ }
223
+ e && this._$AE(i);
224
+ }
225
+ willUpdate(t) {
226
+ }
227
+ _$AE(t) {
228
+ var e;
229
+ (e = this._$ES) === null || e === void 0 || e.forEach((i) => {
230
+ var s;
231
+ return (s = i.hostUpdated) === null || s === void 0 ? void 0 : s.call(i);
232
+ }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
233
+ }
234
+ _$Ek() {
235
+ this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
236
+ }
237
+ get updateComplete() {
238
+ return this.getUpdateComplete();
239
+ }
240
+ getUpdateComplete() {
241
+ return this._$E_;
242
+ }
243
+ shouldUpdate(t) {
244
+ return !0;
245
+ }
246
+ update(t) {
247
+ this._$EC !== void 0 && (this._$EC.forEach((e, i) => this._$EO(i, this[i], e)), this._$EC = void 0), this._$Ek();
248
+ }
249
+ updated(t) {
250
+ }
251
+ firstUpdated(t) {
252
+ }
253
+ };
254
+ E[J] = !0, E.elementProperties = /* @__PURE__ */ new Map(), E.elementStyles = [], E.shadowRootOptions = { mode: "open" }, tt == null || tt({ ReactiveElement: E }), ((j = I.reactiveElementVersions) !== null && j !== void 0 ? j : I.reactiveElementVersions = []).push("1.6.2");
255
+ /**
256
+ * @license
257
+ * Copyright 2017 Google LLC
258
+ * SPDX-License-Identifier: BSD-3-Clause
259
+ */
260
+ var B;
261
+ const k = window, S = k.trustedTypes, et = S ? S.createPolicy("lit-html", { createHTML: (r) => r }) : void 0, Z = "$lit$", f = `lit$${(Math.random() + "").slice(9)}$`, ct = "?" + f, mt = `<${ct}>`, A = document, P = () => A.createComment(""), U = (r) => r === null || typeof r != "object" && typeof r != "function", pt = Array.isArray, At = (r) => pt(r) || typeof (r == null ? void 0 : r[Symbol.iterator]) == "function", F = `[
262
+ \f\r]`, M = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, it = /-->/g, st = />/g, g = RegExp(`>|${F}(?:([^\\s"'>=/]+)(${F}*=${F}*(?:[^
263
+ \f\r"'\`<>=]|("|')|))|$)`, "g"), rt = /'/g, ot = /"/g, ut = /^(?:script|style|textarea|title)$/i, wt = (r) => (t, ...e) => ({ _$litType$: r, strings: t, values: e }), Et = wt(1), b = Symbol.for("lit-noChange"), p = Symbol.for("lit-nothing"), nt = /* @__PURE__ */ new WeakMap(), m = A.createTreeWalker(A, 129, null, !1), St = (r, t) => {
264
+ const e = r.length - 1, i = [];
265
+ let s, n = t === 2 ? "<svg>" : "", o = M;
266
+ for (let l = 0; l < e; l++) {
267
+ const a = r[l];
268
+ let y, h, c = -1, $ = 0;
269
+ for (; $ < a.length && (o.lastIndex = $, h = o.exec(a), h !== null); )
270
+ $ = o.lastIndex, o === M ? h[1] === "!--" ? o = it : h[1] !== void 0 ? o = st : h[2] !== void 0 ? (ut.test(h[2]) && (s = RegExp("</" + h[2], "g")), o = g) : h[3] !== void 0 && (o = g) : o === g ? h[0] === ">" ? (o = s ?? M, c = -1) : h[1] === void 0 ? c = -2 : (c = o.lastIndex - h[2].length, y = h[1], o = h[3] === void 0 ? g : h[3] === '"' ? ot : rt) : o === ot || o === rt ? o = g : o === it || o === st ? o = M : (o = g, s = void 0);
271
+ const N = o === g && r[l + 1].startsWith("/>") ? " " : "";
272
+ n += o === M ? a + mt : c >= 0 ? (i.push(y), a.slice(0, c) + Z + a.slice(c) + f + N) : a + f + (c === -2 ? (i.push(void 0), l) : N);
273
+ }
274
+ const d = n + (r[e] || "<?>") + (t === 2 ? "</svg>" : "");
275
+ if (!Array.isArray(r) || !r.hasOwnProperty("raw"))
276
+ throw Error("invalid template strings array");
277
+ return [et !== void 0 ? et.createHTML(d) : d, i];
278
+ };
279
+ class H {
280
+ constructor({ strings: t, _$litType$: e }, i) {
281
+ let s;
282
+ this.parts = [];
283
+ let n = 0, o = 0;
284
+ const d = t.length - 1, l = this.parts, [a, y] = St(t, e);
285
+ if (this.el = H.createElement(a, i), m.currentNode = this.el.content, e === 2) {
286
+ const h = this.el.content, c = h.firstChild;
287
+ c.remove(), h.append(...c.childNodes);
288
+ }
289
+ for (; (s = m.nextNode()) !== null && l.length < d; ) {
290
+ if (s.nodeType === 1) {
291
+ if (s.hasAttributes()) {
292
+ const h = [];
293
+ for (const c of s.getAttributeNames())
294
+ if (c.endsWith(Z) || c.startsWith(f)) {
295
+ const $ = y[o++];
296
+ if (h.push(c), $ !== void 0) {
297
+ const N = s.getAttribute($.toLowerCase() + Z).split(f), O = /([.?@])?(.*)/.exec($);
298
+ l.push({ type: 1, index: n, name: O[2], strings: N, ctor: O[1] === "." ? Ct : O[1] === "?" ? xt : O[1] === "@" ? Pt : R });
299
+ } else
300
+ l.push({ type: 6, index: n });
301
+ }
302
+ for (const c of h)
303
+ s.removeAttribute(c);
304
+ }
305
+ if (ut.test(s.tagName)) {
306
+ const h = s.textContent.split(f), c = h.length - 1;
307
+ if (c > 0) {
308
+ s.textContent = S ? S.emptyScript : "";
309
+ for (let $ = 0; $ < c; $++)
310
+ s.append(h[$], P()), m.nextNode(), l.push({ type: 2, index: ++n });
311
+ s.append(h[c], P());
312
+ }
313
+ }
314
+ } else if (s.nodeType === 8)
315
+ if (s.data === ct)
316
+ l.push({ type: 2, index: n });
317
+ else {
318
+ let h = -1;
319
+ for (; (h = s.data.indexOf(f, h + 1)) !== -1; )
320
+ l.push({ type: 7, index: n }), h += f.length - 1;
321
+ }
322
+ n++;
323
+ }
324
+ }
325
+ static createElement(t, e) {
326
+ const i = A.createElement("template");
327
+ return i.innerHTML = t, i;
328
+ }
329
+ }
330
+ function C(r, t, e = r, i) {
331
+ var s, n, o, d;
332
+ if (t === b)
333
+ return t;
334
+ let l = i !== void 0 ? (s = e._$Co) === null || s === void 0 ? void 0 : s[i] : e._$Cl;
335
+ const a = U(t) ? void 0 : t._$litDirective$;
336
+ return (l == null ? void 0 : l.constructor) !== a && ((n = l == null ? void 0 : l._$AO) === null || n === void 0 || n.call(l, !1), a === void 0 ? l = void 0 : (l = new a(r), l._$AT(r, e, i)), i !== void 0 ? ((o = (d = e)._$Co) !== null && o !== void 0 ? o : d._$Co = [])[i] = l : e._$Cl = l), l !== void 0 && (t = C(r, l._$AS(r, t.values), l, i)), t;
337
+ }
338
+ class bt {
339
+ constructor(t, e) {
340
+ this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e;
341
+ }
342
+ get parentNode() {
343
+ return this._$AM.parentNode;
344
+ }
345
+ get _$AU() {
346
+ return this._$AM._$AU;
347
+ }
348
+ u(t) {
349
+ var e;
350
+ const { el: { content: i }, parts: s } = this._$AD, n = ((e = t == null ? void 0 : t.creationScope) !== null && e !== void 0 ? e : A).importNode(i, !0);
351
+ m.currentNode = n;
352
+ let o = m.nextNode(), d = 0, l = 0, a = s[0];
353
+ for (; a !== void 0; ) {
354
+ if (d === a.index) {
355
+ let y;
356
+ a.type === 2 ? y = new D(o, o.nextSibling, this, t) : a.type === 1 ? y = new a.ctor(o, a.name, a.strings, this, t) : a.type === 6 && (y = new Ut(o, this, t)), this._$AV.push(y), a = s[++l];
357
+ }
358
+ d !== (a == null ? void 0 : a.index) && (o = m.nextNode(), d++);
359
+ }
360
+ return m.currentNode = A, n;
361
+ }
362
+ v(t) {
363
+ let e = 0;
364
+ for (const i of this._$AV)
365
+ i !== void 0 && (i.strings !== void 0 ? (i._$AI(t, i, e), e += i.strings.length - 2) : i._$AI(t[e])), e++;
366
+ }
367
+ }
368
+ class D {
369
+ constructor(t, e, i, s) {
370
+ var n;
371
+ this.type = 2, this._$AH = p, this._$AN = void 0, this._$AA = t, this._$AB = e, this._$AM = i, this.options = s, this._$Cp = (n = s == null ? void 0 : s.isConnected) === null || n === void 0 || n;
372
+ }
373
+ get _$AU() {
374
+ var t, e;
375
+ return (e = (t = this._$AM) === null || t === void 0 ? void 0 : t._$AU) !== null && e !== void 0 ? e : this._$Cp;
376
+ }
377
+ get parentNode() {
378
+ let t = this._$AA.parentNode;
379
+ const e = this._$AM;
380
+ return e !== void 0 && (t == null ? void 0 : t.nodeType) === 11 && (t = e.parentNode), t;
381
+ }
382
+ get startNode() {
383
+ return this._$AA;
384
+ }
385
+ get endNode() {
386
+ return this._$AB;
387
+ }
388
+ _$AI(t, e = this) {
389
+ t = C(this, t, e), U(t) ? t === p || t == null || t === "" ? (this._$AH !== p && this._$AR(), this._$AH = p) : t !== this._$AH && t !== b && this._(t) : t._$litType$ !== void 0 ? this.g(t) : t.nodeType !== void 0 ? this.$(t) : At(t) ? this.T(t) : this._(t);
390
+ }
391
+ k(t) {
392
+ return this._$AA.parentNode.insertBefore(t, this._$AB);
393
+ }
394
+ $(t) {
395
+ this._$AH !== t && (this._$AR(), this._$AH = this.k(t));
396
+ }
397
+ _(t) {
398
+ this._$AH !== p && U(this._$AH) ? this._$AA.nextSibling.data = t : this.$(A.createTextNode(t)), this._$AH = t;
399
+ }
400
+ g(t) {
401
+ var e;
402
+ const { values: i, _$litType$: s } = t, n = typeof s == "number" ? this._$AC(t) : (s.el === void 0 && (s.el = H.createElement(s.h, this.options)), s);
403
+ if (((e = this._$AH) === null || e === void 0 ? void 0 : e._$AD) === n)
404
+ this._$AH.v(i);
405
+ else {
406
+ const o = new bt(n, this), d = o.u(this.options);
407
+ o.v(i), this.$(d), this._$AH = o;
408
+ }
409
+ }
410
+ _$AC(t) {
411
+ let e = nt.get(t.strings);
412
+ return e === void 0 && nt.set(t.strings, e = new H(t)), e;
413
+ }
414
+ T(t) {
415
+ pt(this._$AH) || (this._$AH = [], this._$AR());
416
+ const e = this._$AH;
417
+ let i, s = 0;
418
+ for (const n of t)
419
+ s === e.length ? e.push(i = new D(this.k(P()), this.k(P()), this, this.options)) : i = e[s], i._$AI(n), s++;
420
+ s < e.length && (this._$AR(i && i._$AB.nextSibling, s), e.length = s);
421
+ }
422
+ _$AR(t = this._$AA.nextSibling, e) {
423
+ var i;
424
+ for ((i = this._$AP) === null || i === void 0 || i.call(this, !1, !0, e); t && t !== this._$AB; ) {
425
+ const s = t.nextSibling;
426
+ t.remove(), t = s;
427
+ }
428
+ }
429
+ setConnected(t) {
430
+ var e;
431
+ this._$AM === void 0 && (this._$Cp = t, (e = this._$AP) === null || e === void 0 || e.call(this, t));
432
+ }
433
+ }
434
+ class R {
435
+ constructor(t, e, i, s, n) {
436
+ this.type = 1, this._$AH = p, this._$AN = void 0, this.element = t, this.name = e, this._$AM = s, this.options = n, i.length > 2 || i[0] !== "" || i[1] !== "" ? (this._$AH = Array(i.length - 1).fill(new String()), this.strings = i) : this._$AH = p;
437
+ }
438
+ get tagName() {
439
+ return this.element.tagName;
440
+ }
441
+ get _$AU() {
442
+ return this._$AM._$AU;
443
+ }
444
+ _$AI(t, e = this, i, s) {
445
+ const n = this.strings;
446
+ let o = !1;
447
+ if (n === void 0)
448
+ t = C(this, t, e, 0), o = !U(t) || t !== this._$AH && t !== b, o && (this._$AH = t);
449
+ else {
450
+ const d = t;
451
+ let l, a;
452
+ for (t = n[0], l = 0; l < n.length - 1; l++)
453
+ a = C(this, d[i + l], e, l), a === b && (a = this._$AH[l]), o || (o = !U(a) || a !== this._$AH[l]), a === p ? t = p : t !== p && (t += (a ?? "") + n[l + 1]), this._$AH[l] = a;
454
+ }
455
+ o && !s && this.j(t);
456
+ }
457
+ j(t) {
458
+ t === p ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
459
+ }
460
+ }
461
+ class Ct extends R {
462
+ constructor() {
463
+ super(...arguments), this.type = 3;
464
+ }
465
+ j(t) {
466
+ this.element[this.name] = t === p ? void 0 : t;
467
+ }
468
+ }
469
+ const Mt = S ? S.emptyScript : "";
470
+ class xt extends R {
471
+ constructor() {
472
+ super(...arguments), this.type = 4;
473
+ }
474
+ j(t) {
475
+ t && t !== p ? this.element.setAttribute(this.name, Mt) : this.element.removeAttribute(this.name);
476
+ }
477
+ }
478
+ class Pt extends R {
479
+ constructor(t, e, i, s, n) {
480
+ super(t, e, i, s, n), this.type = 5;
481
+ }
482
+ _$AI(t, e = this) {
483
+ var i;
484
+ if ((t = (i = C(this, t, e, 0)) !== null && i !== void 0 ? i : p) === b)
485
+ return;
486
+ const s = this._$AH, n = t === p && s !== p || t.capture !== s.capture || t.once !== s.once || t.passive !== s.passive, o = t !== p && (s === p || n);
487
+ n && this.element.removeEventListener(this.name, this, s), o && this.element.addEventListener(this.name, this, t), this._$AH = t;
488
+ }
489
+ handleEvent(t) {
490
+ var e, i;
491
+ typeof this._$AH == "function" ? this._$AH.call((i = (e = this.options) === null || e === void 0 ? void 0 : e.host) !== null && i !== void 0 ? i : this.element, t) : this._$AH.handleEvent(t);
492
+ }
493
+ }
494
+ class Ut {
495
+ constructor(t, e, i) {
496
+ this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = i;
497
+ }
498
+ get _$AU() {
499
+ return this._$AM._$AU;
500
+ }
501
+ _$AI(t) {
502
+ C(this, t);
503
+ }
504
+ }
505
+ const lt = k.litHtmlPolyfillSupport;
506
+ lt == null || lt(H, D), ((B = k.litHtmlVersions) !== null && B !== void 0 ? B : k.litHtmlVersions = []).push("2.7.4");
507
+ const Ht = (r, t, e) => {
508
+ var i, s;
509
+ const n = (i = e == null ? void 0 : e.renderBefore) !== null && i !== void 0 ? i : t;
510
+ let o = n._$litPart$;
511
+ if (o === void 0) {
512
+ const d = (s = e == null ? void 0 : e.renderBefore) !== null && s !== void 0 ? s : null;
513
+ n._$litPart$ = o = new D(t.insertBefore(P(), d), d, void 0, e ?? {});
514
+ }
515
+ return o._$AI(r), o;
516
+ };
517
+ /**
518
+ * @license
519
+ * Copyright 2017 Google LLC
520
+ * SPDX-License-Identifier: BSD-3-Clause
521
+ */
522
+ var q, V;
523
+ class x extends E {
524
+ constructor() {
525
+ super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
526
+ }
527
+ createRenderRoot() {
528
+ var t, e;
529
+ const i = super.createRenderRoot();
530
+ return (t = (e = this.renderOptions).renderBefore) !== null && t !== void 0 || (e.renderBefore = i.firstChild), i;
531
+ }
532
+ update(t) {
533
+ const e = this.render();
534
+ this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = Ht(e, this.renderRoot, this.renderOptions);
535
+ }
536
+ connectedCallback() {
537
+ var t;
538
+ super.connectedCallback(), (t = this._$Do) === null || t === void 0 || t.setConnected(!0);
539
+ }
540
+ disconnectedCallback() {
541
+ var t;
542
+ super.disconnectedCallback(), (t = this._$Do) === null || t === void 0 || t.setConnected(!1);
543
+ }
544
+ render() {
545
+ return b;
546
+ }
547
+ }
548
+ x.finalized = !0, x._$litElement$ = !0, (q = globalThis.litElementHydrateSupport) === null || q === void 0 || q.call(globalThis, { LitElement: x });
549
+ const at = globalThis.litElementPolyfillSupport;
550
+ at == null || at({ LitElement: x });
551
+ ((V = globalThis.litElementVersions) !== null && V !== void 0 ? V : globalThis.litElementVersions = []).push("3.3.2");
552
+ /**
553
+ * @license
554
+ * Copyright 2017 Google LLC
555
+ * SPDX-License-Identifier: BSD-3-Clause
556
+ */
557
+ const Dt = (r) => (t) => typeof t == "function" ? ((e, i) => (customElements.define(e, i), i))(r, t) : ((e, i) => {
558
+ const { kind: s, elements: n } = i;
559
+ return { kind: s, elements: n, finisher(o) {
560
+ customElements.define(e, o);
561
+ } };
562
+ })(r, t);
563
+ /**
564
+ * @license
565
+ * Copyright 2017 Google LLC
566
+ * SPDX-License-Identifier: BSD-3-Clause
567
+ */
568
+ const Nt = (r, t) => t.kind === "method" && t.descriptor && !("value" in t.descriptor) ? { ...t, finisher(e) {
569
+ e.createProperty(t.key, r);
570
+ } } : { kind: "field", key: Symbol(), placement: "own", descriptor: {}, originalKey: t.key, initializer() {
571
+ typeof t.initializer == "function" && (this[t.key] = t.initializer.call(this));
572
+ }, finisher(e) {
573
+ e.createProperty(t.key, r);
574
+ } }, Ot = (r, t, e) => {
575
+ t.constructor.createProperty(e, r);
576
+ };
577
+ function L(r) {
578
+ return (t, e) => e !== void 0 ? Ot(r, t, e) : Nt(r, t);
579
+ }
580
+ /**
581
+ * @license
582
+ * Copyright 2017 Google LLC
583
+ * SPDX-License-Identifier: BSD-3-Clause
584
+ */
585
+ function w(r) {
586
+ return L({ ...r, state: !0 });
587
+ }
588
+ /**
589
+ * @license
590
+ * Copyright 2021 Google LLC
591
+ * SPDX-License-Identifier: BSD-3-Clause
592
+ */
593
+ var W;
594
+ ((W = window.HTMLSlotElement) === null || W === void 0 ? void 0 : W.prototype.assignedElements) != null;
595
+ const Tt = `
596
+ :host {
597
+ display: block;
598
+ }
599
+ `;
600
+ var It = Object.defineProperty, kt = Object.getOwnPropertyDescriptor, v = (r, t, e, i) => {
601
+ for (var s = i > 1 ? void 0 : i ? kt(t, e) : t, n = r.length - 1, o; n >= 0; n--)
602
+ (o = r[n]) && (s = (i ? o(t, e, s) : o(s)) || s);
603
+ return i && s && It(t, e, s), s;
604
+ };
605
+ let _ = class extends x {
606
+ constructor() {
607
+ super(...arguments);
608
+ u(this, "_legacyMode");
609
+ u(this, "_layerId");
610
+ u(this, "_eoxMap");
611
+ u(this, "_olMap");
612
+ u(this, "_drawLayer");
613
+ u(this, "_drawnFeatures", []);
614
+ u(this, "_currentlyDrawing");
615
+ u(this, "multipleFeatures");
616
+ u(this, "for");
617
+ u(this, "layer");
618
+ u(this, "_draw");
619
+ u(this, "_modify");
620
+ }
621
+ async _dynamicImport() {
622
+ const t = this._drawLayer.getSource(), { Draw: e, Modify: i } = await import(
623
+ // @ts-ignore
624
+ "https://cdn.skypack.dev/ol/interaction.js"
625
+ );
626
+ this._draw = new e({
627
+ source: t,
628
+ type: "Polygon"
629
+ }), this._modify = new i({ source: t }), this.requestUpdate();
630
+ }
631
+ _startDrawing() {
632
+ this._legacyMode ? (this._olMap.addInteraction(this._draw), this._olMap.addInteraction(this._modify)) : (this._eoxMap.addDraw(this._layerId, {
633
+ id: "drawInteraction",
634
+ type: "Polygon"
635
+ }), this._draw = this._eoxMap.interactions.drawInteraction, this._modify = this._eoxMap.interactions.drawInteraction_modify), this._draw.on("drawend", (t) => this._onDrawEnd(t)), this._modify.on("modifyend", (t) => this._onModifyEnd(t)), this._currentlyDrawing = !0, this.requestUpdate();
636
+ }
637
+ _discardDrawing() {
638
+ this._drawnFeatures = [], this._legacyMode ? this._olMap.removeInteraction(this._draw) : this._eoxMap.removeInteraction("drawInteraction"), this._drawLayer.getSource().clear(), this._currentlyDrawing = !1, this.requestUpdate();
639
+ }
640
+ _onDrawEnd(t) {
641
+ console.log(t), this._emitDrawnFeatures(), this._legacyMode ? this._olMap.removeInteraction(this._draw) : this._eoxMap.removeInteraction("drawInteraction"), this._currentlyDrawing = !1, this.requestUpdate();
642
+ }
643
+ _onModifyEnd(t) {
644
+ console.log(t), this._emitDrawnFeatures();
645
+ }
646
+ _emitDrawnFeatures() {
647
+ setTimeout(() => {
648
+ this._drawnFeatures = this._drawLayer.getSource().getFeatures(), this.requestUpdate();
649
+ const t = new CustomEvent("drawupdate", {
650
+ detail: this._drawnFeatures
651
+ });
652
+ this.dispatchEvent(t);
653
+ }, 0);
654
+ }
655
+ render() {
656
+ const t = document.querySelector(this.for);
657
+ this._layerId = this.layer, t.addDraw ? (this._eoxMap = t, this._olMap = t.map) : (this._legacyMode = !0, this._olMap = t);
658
+ let e;
659
+ return e = this._olMap.getLayers().getArray(), this._drawLayer = e.find(
660
+ (i) => i.get("id") === this._layerId
661
+ ) || e.filter((i) => i.get("mapbox-layers")).find(
662
+ (i) => i.get("mapbox-layers").includes(this._layerId)
663
+ ), this._legacyMode && this._dynamicImport(), this.requestUpdate(), Et`
664
+ <style>
665
+ ${Tt}
666
+ </style>
667
+ <div>
668
+ <slot></slot>
669
+ <button
670
+ disabled="${this._legacyMode && !this._draw || !this.multipleFeatures && this._drawnFeatures.length || this._currentlyDrawing || p}"
671
+ @click="${() => this._startDrawing()}"
672
+ >
673
+ ${this._currentlyDrawing ? "drawing" : "draw"}
674
+ </button>
675
+ <button
676
+ disabled="${!this._drawnFeatures.length && !this._currentlyDrawing || p}"
677
+ @click="${() => this._discardDrawing()}"
678
+ >
679
+ discard
680
+ </button>
681
+ </div>
682
+ `;
683
+ }
684
+ };
685
+ v([
686
+ w()
687
+ ], _.prototype, "_legacyMode", 2);
688
+ v([
689
+ w()
690
+ ], _.prototype, "_layerId", 2);
691
+ v([
692
+ w()
693
+ ], _.prototype, "_eoxMap", 2);
694
+ v([
695
+ w()
696
+ ], _.prototype, "_olMap", 2);
697
+ v([
698
+ w()
699
+ ], _.prototype, "_drawLayer", 2);
700
+ v([
701
+ w()
702
+ ], _.prototype, "_drawnFeatures", 2);
703
+ v([
704
+ w()
705
+ ], _.prototype, "_currentlyDrawing", 2);
706
+ v([
707
+ L({ type: Boolean })
708
+ ], _.prototype, "multipleFeatures", 2);
709
+ v([
710
+ L()
711
+ ], _.prototype, "for", 2);
712
+ v([
713
+ L()
714
+ ], _.prototype, "layer", 2);
715
+ _ = v([
716
+ Dt("eox-drawtools")
717
+ ], _);
718
+ export {
719
+ _ as EOxDrawTools
720
+ };
@@ -0,0 +1,58 @@
1
+ (function(d,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(d=typeof globalThis<"u"?globalThis:d||self,_(d["eox-drawtools"]={}))})(this,function(d){"use strict";var It=Object.defineProperty;var kt=(d,_,f)=>_ in d?It(d,_,{enumerable:!0,configurable:!0,writable:!0,value:f}):d[_]=f;var $=(d,_,f)=>(kt(d,typeof _!="symbol"?_+"":_,f),f);/**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */const _=window,f=_.ShadowRoot&&(_.ShadyCSS===void 0||_.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Q=Symbol(),X=new WeakMap;let _t=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Q)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(f&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=X.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&X.set(e,t))}return t}toString(){return this.cssText}};const $t=r=>new _t(typeof r=="string"?r:r+"",void 0,Q),vt=(r,t)=>{f?r.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet):t.forEach(e=>{const i=document.createElement("style"),s=_.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=e.cssText,r.appendChild(i)})},Y=f?r=>r:r=>r instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return $t(e)})(r):r;/**
6
+ * @license
7
+ * Copyright 2017 Google LLC
8
+ * SPDX-License-Identifier: BSD-3-Clause
9
+ */var z;const N=window,tt=N.trustedTypes,yt=tt?tt.emptyScript:"",et=N.reactiveElementPolyfillSupport,B={toAttribute(r,t){switch(t){case Boolean:r=r?yt:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,t){let e=r;switch(t){case Boolean:e=r!==null;break;case Number:e=r===null?null:Number(r);break;case Object:case Array:try{e=JSON.parse(r)}catch{e=null}}return e}},it=(r,t)=>t!==r&&(t==t||r==r),F={attribute:!0,type:String,converter:B,reflect:!1,hasChanged:it},q="finalized";let b=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u()}static addInitializer(t){var e;this.finalize(),((e=this.h)!==null&&e!==void 0?e:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach((e,i)=>{const s=this._$Ep(i,e);s!==void 0&&(this._$Ev.set(s,i),t.push(s))}),t}static createProperty(t,e=F){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i=typeof t=="symbol"?Symbol():"__"+t,s=this.getPropertyDescriptor(t,i,e);s!==void 0&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(s){const n=this[t];this[e]=s,this.requestUpdate(t,n,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||F}static finalize(){if(this.hasOwnProperty(q))return!1;this[q]=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const e=this.properties,i=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const s of i)this.createProperty(s,e[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)e.unshift(Y(s))}else t!==void 0&&e.push(Y(t));return e}static _$Ep(t,e){const i=e.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(e=>e(this))}addController(t){var e,i;((e=this._$ES)!==null&&e!==void 0?e:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((i=t.hostConnected)===null||i===void 0||i.call(t))}removeController(t){var e;(e=this._$ES)===null||e===void 0||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])})}createRenderRoot(){var t;const e=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return vt(e,this.constructor.elementStyles),e}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(e=>{var i;return(i=e.hostConnected)===null||i===void 0?void 0:i.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(e=>{var i;return(i=e.hostDisconnected)===null||i===void 0?void 0:i.call(e)})}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e,i=F){var s;const n=this.constructor._$Ep(t,i);if(n!==void 0&&i.reflect===!0){const o=(((s=i.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?i.converter:B).toAttribute(e,i.type);this._$El=t,o==null?this.removeAttribute(n):this.setAttribute(n,o),this._$El=null}}_$AK(t,e){var i;const s=this.constructor,n=s._$Ev.get(t);if(n!==void 0&&this._$El!==n){const o=s.getPropertyOptions(n),u=typeof o.converter=="function"?{fromAttribute:o.converter}:((i=o.converter)===null||i===void 0?void 0:i.fromAttribute)!==void 0?o.converter:B;this._$El=n,this[n]=u.fromAttribute(e,o.type),this._$El=null}}requestUpdate(t,e,i){let s=!0;t!==void 0&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||it)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),i.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,i))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((s,n)=>this[n]=s),this._$Ei=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),(t=this._$ES)===null||t===void 0||t.forEach(s=>{var n;return(n=s.hostUpdate)===null||n===void 0?void 0:n.call(s)}),this.update(i)):this._$Ek()}catch(s){throw e=!1,this._$Ek(),s}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;(e=this._$ES)===null||e===void 0||e.forEach(i=>{var s;return(s=i.hostUpdated)===null||s===void 0?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((e,i)=>this._$EO(i,this[i],e)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};b[q]=!0,b.elementProperties=new Map,b.elementStyles=[],b.shadowRootOptions={mode:"open"},et==null||et({ReactiveElement:b}),((z=N.reactiveElementVersions)!==null&&z!==void 0?z:N.reactiveElementVersions=[]).push("1.6.2");/**
10
+ * @license
11
+ * Copyright 2017 Google LLC
12
+ * SPDX-License-Identifier: BSD-3-Clause
13
+ */var V;const I=window,C=I.trustedTypes,st=C?C.createPolicy("lit-html",{createHTML:r=>r}):void 0,W="$lit$",m=`lit$${(Math.random()+"").slice(9)}$`,rt="?"+m,ft=`<${rt}>`,A=document,T=()=>A.createComment(""),D=r=>r===null||typeof r!="object"&&typeof r!="function",ot=Array.isArray,gt=r=>ot(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",K=`[
14
+ \f\r]`,O=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,nt=/-->/g,lt=/>/g,w=RegExp(`>|${K}(?:([^\\s"'>=/]+)(${K}*=${K}*(?:[^
15
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),at=/'/g,ht=/"/g,dt=/^(?:script|style|textarea|title)$/i,mt=r=>(t,...e)=>({_$litType$:r,strings:t,values:e}),At=mt(1),x=Symbol.for("lit-noChange"),c=Symbol.for("lit-nothing"),ct=new WeakMap,E=A.createTreeWalker(A,129,null,!1),wt=(r,t)=>{const e=r.length-1,i=[];let s,n=t===2?"<svg>":"",o=O;for(let l=0;l<e;l++){const a=r[l];let g,h,p=-1,y=0;for(;y<a.length&&(o.lastIndex=y,h=o.exec(a),h!==null);)y=o.lastIndex,o===O?h[1]==="!--"?o=nt:h[1]!==void 0?o=lt:h[2]!==void 0?(dt.test(h[2])&&(s=RegExp("</"+h[2],"g")),o=w):h[3]!==void 0&&(o=w):o===w?h[0]===">"?(o=s??O,p=-1):h[1]===void 0?p=-2:(p=o.lastIndex-h[2].length,g=h[1],o=h[3]===void 0?w:h[3]==='"'?ht:at):o===ht||o===at?o=w:o===nt||o===lt?o=O:(o=w,s=void 0);const L=o===w&&r[l+1].startsWith("/>")?" ":"";n+=o===O?a+ft:p>=0?(i.push(g),a.slice(0,p)+W+a.slice(p)+m+L):a+m+(p===-2?(i.push(void 0),l):L)}const u=n+(r[e]||"<?>")+(t===2?"</svg>":"");if(!Array.isArray(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return[st!==void 0?st.createHTML(u):u,i]};class P{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let n=0,o=0;const u=t.length-1,l=this.parts,[a,g]=wt(t,e);if(this.el=P.createElement(a,i),E.currentNode=this.el.content,e===2){const h=this.el.content,p=h.firstChild;p.remove(),h.append(...p.childNodes)}for(;(s=E.nextNode())!==null&&l.length<u;){if(s.nodeType===1){if(s.hasAttributes()){const h=[];for(const p of s.getAttributeNames())if(p.endsWith(W)||p.startsWith(m)){const y=g[o++];if(h.push(p),y!==void 0){const L=s.getAttribute(y.toLowerCase()+W).split(m),j=/([.?@])?(.*)/.exec(y);l.push({type:1,index:n,name:j[2],strings:L,ctor:j[1]==="."?St:j[1]==="?"?Ct:j[1]==="@"?xt:k})}else l.push({type:6,index:n})}for(const p of h)s.removeAttribute(p)}if(dt.test(s.tagName)){const h=s.textContent.split(m),p=h.length-1;if(p>0){s.textContent=C?C.emptyScript:"";for(let y=0;y<p;y++)s.append(h[y],T()),E.nextNode(),l.push({type:2,index:++n});s.append(h[p],T())}}}else if(s.nodeType===8)if(s.data===rt)l.push({type:2,index:n});else{let h=-1;for(;(h=s.data.indexOf(m,h+1))!==-1;)l.push({type:7,index:n}),h+=m.length-1}n++}}static createElement(t,e){const i=A.createElement("template");return i.innerHTML=t,i}}function M(r,t,e=r,i){var s,n,o,u;if(t===x)return t;let l=i!==void 0?(s=e._$Co)===null||s===void 0?void 0:s[i]:e._$Cl;const a=D(t)?void 0:t._$litDirective$;return(l==null?void 0:l.constructor)!==a&&((n=l==null?void 0:l._$AO)===null||n===void 0||n.call(l,!1),a===void 0?l=void 0:(l=new a(r),l._$AT(r,e,i)),i!==void 0?((o=(u=e)._$Co)!==null&&o!==void 0?o:u._$Co=[])[i]=l:e._$Cl=l),l!==void 0&&(t=M(r,l._$AS(r,t.values),l,i)),t}class Et{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var e;const{el:{content:i},parts:s}=this._$AD,n=((e=t==null?void 0:t.creationScope)!==null&&e!==void 0?e:A).importNode(i,!0);E.currentNode=n;let o=E.nextNode(),u=0,l=0,a=s[0];for(;a!==void 0;){if(u===a.index){let g;a.type===2?g=new U(o,o.nextSibling,this,t):a.type===1?g=new a.ctor(o,a.name,a.strings,this,t):a.type===6&&(g=new Mt(o,this,t)),this._$AV.push(g),a=s[++l]}u!==(a==null?void 0:a.index)&&(o=E.nextNode(),u++)}return E.currentNode=A,n}v(t){let e=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class U{constructor(t,e,i,s){var n;this.type=2,this._$AH=c,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cp=(n=s==null?void 0:s.isConnected)===null||n===void 0||n}get _$AU(){var t,e;return(e=(t=this._$AM)===null||t===void 0?void 0:t._$AU)!==null&&e!==void 0?e:this._$Cp}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=M(this,t,e),D(t)?t===c||t==null||t===""?(this._$AH!==c&&this._$AR(),this._$AH=c):t!==this._$AH&&t!==x&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):gt(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==c&&D(this._$AH)?this._$AA.nextSibling.data=t:this.$(A.createTextNode(t)),this._$AH=t}g(t){var e;const{values:i,_$litType$:s}=t,n=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=P.createElement(s.h,this.options)),s);if(((e=this._$AH)===null||e===void 0?void 0:e._$AD)===n)this._$AH.v(i);else{const o=new Et(n,this),u=o.u(this.options);o.v(i),this.$(u),this._$AH=o}}_$AC(t){let e=ct.get(t.strings);return e===void 0&&ct.set(t.strings,e=new P(t)),e}T(t){ot(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const n of t)s===e.length?e.push(i=new U(this.k(T()),this.k(T()),this,this.options)):i=e[s],i._$AI(n),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)===null||i===void 0||i.call(this,!1,!0,e);t&&t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){var e;this._$AM===void 0&&(this._$Cp=t,(e=this._$AP)===null||e===void 0||e.call(this,t))}}class k{constructor(t,e,i,s,n){this.type=1,this._$AH=c,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=n,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=c}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,s){const n=this.strings;let o=!1;if(n===void 0)t=M(this,t,e,0),o=!D(t)||t!==this._$AH&&t!==x,o&&(this._$AH=t);else{const u=t;let l,a;for(t=n[0],l=0;l<n.length-1;l++)a=M(this,u[i+l],e,l),a===x&&(a=this._$AH[l]),o||(o=!D(a)||a!==this._$AH[l]),a===c?t=c:t!==c&&(t+=(a??"")+n[l+1]),this._$AH[l]=a}o&&!s&&this.j(t)}j(t){t===c?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class St extends k{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===c?void 0:t}}const bt=C?C.emptyScript:"";class Ct extends k{constructor(){super(...arguments),this.type=4}j(t){t&&t!==c?this.element.setAttribute(this.name,bt):this.element.removeAttribute(this.name)}}class xt extends k{constructor(t,e,i,s,n){super(t,e,i,s,n),this.type=5}_$AI(t,e=this){var i;if((t=(i=M(this,t,e,0))!==null&&i!==void 0?i:c)===x)return;const s=this._$AH,n=t===c&&s!==c||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,o=t!==c&&(s===c||n);n&&this.element.removeEventListener(this.name,this,s),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,i;typeof this._$AH=="function"?this._$AH.call((i=(e=this.options)===null||e===void 0?void 0:e.host)!==null&&i!==void 0?i:this.element,t):this._$AH.handleEvent(t)}}class Mt{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){M(this,t)}}const ut=I.litHtmlPolyfillSupport;ut==null||ut(P,U),((V=I.litHtmlVersions)!==null&&V!==void 0?V:I.litHtmlVersions=[]).push("2.7.4");const Tt=(r,t,e)=>{var i,s;const n=(i=e==null?void 0:e.renderBefore)!==null&&i!==void 0?i:t;let o=n._$litPart$;if(o===void 0){const u=(s=e==null?void 0:e.renderBefore)!==null&&s!==void 0?s:null;n._$litPart$=o=new U(t.insertBefore(T(),u),u,void 0,e??{})}return o._$AI(r),o};/**
16
+ * @license
17
+ * Copyright 2017 Google LLC
18
+ * SPDX-License-Identifier: BSD-3-Clause
19
+ */var J,Z;class H extends b{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,e;const i=super.createRenderRoot();return(t=(e=this.renderOptions).renderBefore)!==null&&t!==void 0||(e.renderBefore=i.firstChild),i}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Tt(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!1)}render(){return x}}H.finalized=!0,H._$litElement$=!0,(J=globalThis.litElementHydrateSupport)===null||J===void 0||J.call(globalThis,{LitElement:H});const pt=globalThis.litElementPolyfillSupport;pt==null||pt({LitElement:H}),((Z=globalThis.litElementVersions)!==null&&Z!==void 0?Z:globalThis.litElementVersions=[]).push("3.3.2");/**
20
+ * @license
21
+ * Copyright 2017 Google LLC
22
+ * SPDX-License-Identifier: BSD-3-Clause
23
+ */const Dt=r=>t=>typeof t=="function"?((e,i)=>(customElements.define(e,i),i))(r,t):((e,i)=>{const{kind:s,elements:n}=i;return{kind:s,elements:n,finisher(o){customElements.define(e,o)}}})(r,t);/**
24
+ * @license
25
+ * Copyright 2017 Google LLC
26
+ * SPDX-License-Identifier: BSD-3-Clause
27
+ */const Ot=(r,t)=>t.kind==="method"&&t.descriptor&&!("value"in t.descriptor)?{...t,finisher(e){e.createProperty(t.key,r)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){typeof t.initializer=="function"&&(this[t.key]=t.initializer.call(this))},finisher(e){e.createProperty(t.key,r)}},Pt=(r,t,e)=>{t.constructor.createProperty(e,r)};function R(r){return(t,e)=>e!==void 0?Pt(r,t,e):Ot(r,t)}/**
28
+ * @license
29
+ * Copyright 2017 Google LLC
30
+ * SPDX-License-Identifier: BSD-3-Clause
31
+ */function S(r){return R({...r,state:!0})}/**
32
+ * @license
33
+ * Copyright 2021 Google LLC
34
+ * SPDX-License-Identifier: BSD-3-Clause
35
+ */var G;((G=window.HTMLSlotElement)===null||G===void 0?void 0:G.prototype.assignedElements)!=null;const Ut=`
36
+ :host {
37
+ display: block;
38
+ }
39
+ `;var Ht=Object.defineProperty,Nt=Object.getOwnPropertyDescriptor,v=(r,t,e,i)=>{for(var s=i>1?void 0:i?Nt(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Ht(t,e,s),s};d.EOxDrawTools=class extends H{constructor(){super(...arguments);$(this,"_legacyMode");$(this,"_layerId");$(this,"_eoxMap");$(this,"_olMap");$(this,"_drawLayer");$(this,"_drawnFeatures",[]);$(this,"_currentlyDrawing");$(this,"multipleFeatures");$(this,"for");$(this,"layer");$(this,"_draw");$(this,"_modify")}async _dynamicImport(){const e=this._drawLayer.getSource(),{Draw:i,Modify:s}=await import("https://cdn.skypack.dev/ol/interaction.js");this._draw=new i({source:e,type:"Polygon"}),this._modify=new s({source:e}),this.requestUpdate()}_startDrawing(){this._legacyMode?(this._olMap.addInteraction(this._draw),this._olMap.addInteraction(this._modify)):(this._eoxMap.addDraw(this._layerId,{id:"drawInteraction",type:"Polygon"}),this._draw=this._eoxMap.interactions.drawInteraction,this._modify=this._eoxMap.interactions.drawInteraction_modify),this._draw.on("drawend",e=>this._onDrawEnd(e)),this._modify.on("modifyend",e=>this._onModifyEnd(e)),this._currentlyDrawing=!0,this.requestUpdate()}_discardDrawing(){this._drawnFeatures=[],this._legacyMode?this._olMap.removeInteraction(this._draw):this._eoxMap.removeInteraction("drawInteraction"),this._drawLayer.getSource().clear(),this._currentlyDrawing=!1,this.requestUpdate()}_onDrawEnd(e){console.log(e),this._emitDrawnFeatures(),this._legacyMode?this._olMap.removeInteraction(this._draw):this._eoxMap.removeInteraction("drawInteraction"),this._currentlyDrawing=!1,this.requestUpdate()}_onModifyEnd(e){console.log(e),this._emitDrawnFeatures()}_emitDrawnFeatures(){setTimeout(()=>{this._drawnFeatures=this._drawLayer.getSource().getFeatures(),this.requestUpdate();const e=new CustomEvent("drawupdate",{detail:this._drawnFeatures});this.dispatchEvent(e)},0)}render(){const e=document.querySelector(this.for);this._layerId=this.layer,e.addDraw?(this._eoxMap=e,this._olMap=e.map):(this._legacyMode=!0,this._olMap=e);let i;return i=this._olMap.getLayers().getArray(),this._drawLayer=i.find(s=>s.get("id")===this._layerId)||i.filter(s=>s.get("mapbox-layers")).find(s=>s.get("mapbox-layers").includes(this._layerId)),this._legacyMode&&this._dynamicImport(),this.requestUpdate(),At`
40
+ <style>
41
+ ${Ut}
42
+ </style>
43
+ <div>
44
+ <slot></slot>
45
+ <button
46
+ disabled="${this._legacyMode&&!this._draw||!this.multipleFeatures&&this._drawnFeatures.length||this._currentlyDrawing||c}"
47
+ @click="${()=>this._startDrawing()}"
48
+ >
49
+ ${this._currentlyDrawing?"drawing":"draw"}
50
+ </button>
51
+ <button
52
+ disabled="${!this._drawnFeatures.length&&!this._currentlyDrawing||c}"
53
+ @click="${()=>this._discardDrawing()}"
54
+ >
55
+ discard
56
+ </button>
57
+ </div>
58
+ `}},v([S()],d.EOxDrawTools.prototype,"_legacyMode",2),v([S()],d.EOxDrawTools.prototype,"_layerId",2),v([S()],d.EOxDrawTools.prototype,"_eoxMap",2),v([S()],d.EOxDrawTools.prototype,"_olMap",2),v([S()],d.EOxDrawTools.prototype,"_drawLayer",2),v([S()],d.EOxDrawTools.prototype,"_drawnFeatures",2),v([S()],d.EOxDrawTools.prototype,"_currentlyDrawing",2),v([R({type:Boolean})],d.EOxDrawTools.prototype,"multipleFeatures",2),v([R()],d.EOxDrawTools.prototype,"for",2),v([R()],d.EOxDrawTools.prototype,"layer",2),d.EOxDrawTools=v([Dt("eox-drawtools")],d.EOxDrawTools),Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@eox/drawtools",
3
+ "version": "0.2.0",
4
+ "type": "module",
5
+ "devDependencies": {
6
+ "@eox/eslint-config": "^1.0.0",
7
+ "@typescript-eslint/eslint-plugin": "^5.50.0",
8
+ "@typescript-eslint/parser": "^5.50.0",
9
+ "eslint-plugin-typescript": "^0.14.0",
10
+ "ol": "^7.3.0",
11
+ "typescript": "^4.9.3",
12
+ "vite": "^4.0.0"
13
+ },
14
+ "engines": {
15
+ "npm": ">=8.0.0",
16
+ "node": ">=18.0.0"
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "test"
21
+ ],
22
+ "main": "./dist/eox-drawtools.js",
23
+ "scripts": {
24
+ "start": "vite",
25
+ "build": "tsc && vite build",
26
+ "watch": "tsc && vite build --watch",
27
+ "format": "prettier --write .",
28
+ "lint": "eslint --ext .js,.ts .",
29
+ "lint:fix": "eslint --ext .js,.ts . --fix"
30
+ },
31
+ "dependencies": {
32
+ "lit": "^2.7.4"
33
+ }
34
+ }
@@ -0,0 +1,9 @@
1
+ describe("Drawtools", () => {
2
+ beforeEach(() => {
3
+ cy.visit("/elements/drawtools/test/mapIntegration.html");
4
+ });
5
+
6
+ it("loads the drawtools", () => {
7
+ cy.get("eox-drawtools").should("exist");
8
+ });
9
+ });
@@ -0,0 +1,43 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <style>
5
+ html,
6
+ body {
7
+ padding: 0;
8
+ margin: 0;
9
+ }
10
+ eox-map {
11
+ width: 100%;
12
+ height: 400px;
13
+ }
14
+ eox-drawtools {
15
+ position: absolute;
16
+ top: 0;
17
+ right: 0;
18
+ background: white;
19
+ }
20
+ </style>
21
+ <script type="module" defer src="../../map/dist/eox-map.js"></script>
22
+ <script type="module" defer src="../dist/eox-drawtools.js"></script>
23
+ </head>
24
+ <body>
25
+ <eox-map></eox-map>
26
+ <eox-drawtools> Default slot content </eox-drawtools>
27
+ <p>Drawn features: <span style="line-break: anywhere"></span></p>
28
+ <script type="module">
29
+ import layers from "./mapIntegration.json" assert { type: "json" };
30
+ const eoxMap = document.querySelector("eox-map");
31
+ const eoxDrawTools = document.querySelector("eox-drawtools");
32
+ setTimeout(() => {
33
+ eoxMap.setLayers(layers);
34
+ eoxDrawTools.attachTo(eoxMap, "draw_layer");
35
+ }, 500);
36
+ eoxDrawTools.addEventListener("drawupdate", (evt) => {
37
+ document.querySelector("span").innerHTML = JSON.stringify(
38
+ evt.detail.map((f) => f.getGeometry().flatCoordinates)
39
+ );
40
+ });
41
+ </script>
42
+ </body>
43
+ </html>
@@ -0,0 +1,89 @@
1
+ {
2
+ "version": 8,
3
+ "name": "",
4
+ "sources": {
5
+ "states": {
6
+ "type": "raster",
7
+ "tileSize": 512,
8
+ "tiles": [
9
+ "https://ahocevar.com/geoserver/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image/png&TRANSPARENT=true&LAYERS=topp:states&STYLES=&WIDTH=512&HEIGHT=512&SRS=EPSG:3857&BBOX={bbox-epsg-3857}"
10
+ ]
11
+ },
12
+ "countries": {
13
+ "type": "geojson",
14
+ "data": "https://openlayersbook.github.io/openlayers_book_samples/assets/data/countries.geojson"
15
+ },
16
+ "countriesTiles": {
17
+ "type": "vector",
18
+ "tiles": [
19
+ "https://ahocevar.com/geoserver/gwc/service/tms/1.0.0/ne:ne_10m_admin_0_countries@EPSG%3A900913@pbf/{z}/{x}/{-y}.pbf"
20
+ ]
21
+ },
22
+ "draw_layer": {
23
+ "type": "geojson",
24
+ "data": {
25
+ "type": "FeatureCollection",
26
+ "features": []
27
+ }
28
+ }
29
+ },
30
+ "layers": [
31
+ {
32
+ "id": "states",
33
+ "type": "raster",
34
+ "source": "states"
35
+ },
36
+ {
37
+ "id": "countries_fill",
38
+ "type": "fill",
39
+ "source": "countries",
40
+ "paint": {
41
+ "fill-color": "rgba(255, 255, 255, 0.5)"
42
+ }
43
+ },
44
+ {
45
+ "id": "countries_outline",
46
+ "type": "line",
47
+ "source": "countries",
48
+ "paint": {
49
+ "line-color": "#219e46",
50
+ "line-width": 2
51
+ }
52
+ },
53
+ {
54
+ "id": "countries_fill_tiles",
55
+ "type": "fill",
56
+ "source": "countriesTiles",
57
+ "source-layer": "ne_10m_admin_0_countries",
58
+ "paint": {
59
+ "fill-color": "rgba(255, 0, 100, 0.5)"
60
+ }
61
+ },
62
+ {
63
+ "id": "countries_outline_tiles",
64
+ "type": "line",
65
+ "source": "countriesTiles",
66
+ "source-layer": "ne_10m_admin_0_countries",
67
+ "paint": {
68
+ "line-color": "rgba(255, 0, 100, 1)"
69
+ }
70
+ },
71
+ {
72
+ "id": "draw_layer",
73
+ "type": "line",
74
+ "source": "draw_layer",
75
+ "metadata": {
76
+ "group": "draw_layer",
77
+ "draw": {
78
+ "active": true,
79
+ "type": "LineString"
80
+ }
81
+ },
82
+ "paint": {
83
+ "line-color": "blue",
84
+ "fill-color": "rgba(255,255,255,0.4)",
85
+ "line-width": 2
86
+ }
87
+ }
88
+ ]
89
+ }
@@ -0,0 +1,9 @@
1
+ describe("Drawtools", () => {
2
+ beforeEach(() => {
3
+ cy.visit("/elements/drawtools/test/mapIntegrationLegacy.html");
4
+ });
5
+
6
+ it("loads the drawtools", () => {
7
+ cy.get("eox-drawtools").should("exist");
8
+ });
9
+ });
@@ -0,0 +1,64 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <style>
5
+ html,
6
+ body {
7
+ padding: 0;
8
+ margin: 0;
9
+ }
10
+ #map {
11
+ width: 100%;
12
+ height: 400px;
13
+ }
14
+ eox-drawtools {
15
+ position: absolute;
16
+ top: 0;
17
+ right: 0;
18
+ background: white;
19
+ }
20
+ </style>
21
+ <script type="module" defer src="../../map/dist/eox-map.js"></script>
22
+ <script type="module" defer src="../dist/eox-drawtools.js"></script>
23
+ </head>
24
+ <body>
25
+ <div id="map"></div>
26
+ <eox-drawtools> Default slot content </eox-drawtools>
27
+ <p>Drawn features: <span style="line-break: anywhere"></span></p>
28
+ <script type="module">
29
+ import Map from "https://cdn.skypack.dev/ol/Map.js";
30
+ import OSM from "https://cdn.skypack.dev/ol/source/OSM.js";
31
+ import TileLayer from "https://cdn.skypack.dev/ol/layer/Tile.js";
32
+ import View from "https://cdn.skypack.dev/ol/View.js";
33
+ import VectorLayer from "https://cdn.skypack.dev/ol/layer/Vector.js";
34
+ import VectorSource from "https://cdn.skypack.dev/ol/source/Vector.js";
35
+
36
+ const map = new Map({
37
+ target: "map",
38
+ layers: [
39
+ new TileLayer({
40
+ source: new OSM(),
41
+ }),
42
+ new VectorLayer({
43
+ source: new VectorSource(),
44
+ id: "draw_layer",
45
+ }),
46
+ ],
47
+ view: new View({
48
+ center: [0, 0],
49
+ zoom: 2,
50
+ }),
51
+ controls: [],
52
+ });
53
+ const eoxDrawTools = document.querySelector("eox-drawtools");
54
+ setTimeout(() => {
55
+ eoxDrawTools.attachTo(map, "draw_layer");
56
+ }, 500);
57
+ eoxDrawTools.addEventListener("drawupdate", (evt) => {
58
+ document.querySelector("span").innerHTML = JSON.stringify(
59
+ evt.detail.map((f) => f.getGeometry().flatCoordinates)
60
+ );
61
+ });
62
+ </script>
63
+ </body>
64
+ </html>