@yappkit/front-module-map 0.1.8 → 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.
@@ -1,333 +1,288 @@
1
- import { defineComponent as p, ref as y, toRefs as u, shallowRef as g, provide as m, watch as c, h as v, inject as f, onMounted as L, onUnmounted as M, nextTick as O, toRaw as k } from "vue";
2
- class b {
3
- constructor({ unwatchFn: e }) {
4
- this.overlay = null, this.watching = { options: !1, layers: !1 }, this.unwatchFn = e;
5
- }
6
- watchOptions(e, s = {}) {
7
- if (!this.overlay)
8
- throw new Error("overlay should be set");
9
- if (this.watching.options) {
10
- console.warn("No need to call GoogleMapsDeckGLOverlay.watchOptions(). options are already being watched");
11
- return;
12
- }
13
- this.watching.options = !0;
14
- const t = c(e, () => {
15
- this.overlay.setProps({ ...e.value });
16
- }, {
17
- immediate: !0,
18
- deep: !0,
19
- ...s
20
- });
21
- this.unwatchFn.push(t);
22
- }
23
- watchLayers(e, s = {}) {
24
- if (!this.overlay)
25
- throw new Error("overlay should be set");
26
- if (this.watching.layers) {
27
- console.warn("No need to call GoogleMapsDeckGLOverlay.watchLayers(). layers are already being watched");
28
- return;
29
- }
30
- this.watching.layers = !0;
31
- const t = c(e, () => {
32
- this.overlay.setProps({ layers: e.value });
33
- }, {
34
- immediate: !0,
35
- ...s
36
- });
37
- this.unwatchFn.push(t);
38
- }
39
- }
40
- class G {
41
- constructor() {
42
- this.map = null, this.unwatchFn = [];
43
- }
44
- async setDeckGLOverlay(e = {}) {
45
- if (!this.map)
46
- throw new Error("map should be set");
47
- const { GoogleMapsOverlay: s } = await import("@deck.gl/google-maps"), t = new b({ unwatchFn: this.unwatchFn });
48
- return t.overlay = new s(e), t.overlay.setMap(this.map), t;
49
- }
50
- }
51
- class D {
52
- constructor() {
53
- this.map = null, this.watching = { options: !1, layers: !1 }, this.unwatchFn = [];
54
- }
55
- _getSetters(e) {
56
- const s = [], t = { ...Object.getOwnPropertyDescriptors(Object.getPrototypeOf(e)) };
57
- for (const [r, a] of Object.entries(t))
58
- a.enumerable && s.push(r);
59
- return s;
60
- }
61
- _getOptions(e) {
62
- const s = {}, t = this._getSetters(e);
63
- for (const r of t) {
64
- let a = e[r];
65
- e[r] instanceof Object && (a = this._getOptions(e[r])), s[r] = a;
66
- }
67
- return s;
68
- }
69
- setProps(e = {}) {
70
- for (const [s, t] of Object.entries(e))
71
- this.map[s] = t;
72
- }
73
- getProps() {
74
- return this._getOptions(this.map);
75
- }
76
- getLayer(e) {
77
- if (!this.map)
78
- throw new Error("map should be set");
79
- return this.map.children.namedItem(e);
80
- }
81
- watchOptions(e, s = {}) {
82
- if (!this.map)
83
- throw new Error("map should be set");
84
- if (this.watching.options) {
85
- console.warn("No need to call GoogleMapsMap3D.watchOptions(). options are already being watched");
86
- return;
87
- }
88
- this.watching.options = !0;
89
- let t = {};
90
- const r = c(e, async () => {
91
- await O();
92
- const a = k(e.value);
93
- for (const [o, n] of Object.entries(a))
94
- JSON.stringify(n) !== JSON.stringify(t[o]) && (this.map[o] = n);
95
- t = structuredClone(a);
96
- }, {
97
- immediate: !0,
98
- deep: !0,
99
- ...s
100
- });
101
- this.unwatchFn.push(r);
102
- }
103
- watchLayers(e, s = {}) {
104
- if (!this.map)
105
- throw new Error("map should be set");
106
- if (this.watching.layers) {
107
- console.warn("No need to call GoogleMapsMap3D.watchLayers(). layers are already being watched");
108
- return;
109
- }
110
- this.watching.layers = !0;
111
- const t = c(e, async (r, a) => {
112
- const o = a || [], n = r || [], i = n.filter((l, w) => l !== o[w]), h = o.filter((l, w) => l !== n[w]);
113
- await O();
114
- for (const l of h)
115
- this.map.children.namedItem(l.id).remove();
116
- for (const l of i)
117
- l.element.setAttribute("name", l.id), this.map.appendChild(l.element);
118
- }, {
119
- immediate: !0,
120
- ...s
121
- });
122
- this.unwatchFn.push(t);
123
- }
124
- }
125
- class F {
126
- constructor(e) {
127
- if (this.apiKey = e.apiKey, !this.apiKey)
128
- throw new Error("apiKey is required");
129
- this.libraries = [...e.libraries || []], this.version = e.version || "weekly", this.loader = null, this.sdk = {}, this.deckgl = null, this.getSDK();
130
- }
131
- get Map() {
132
- return p(
133
- (e, { emit: s, slots: t }) => {
134
- const r = y(null), { options: a } = u(e), o = g(null);
135
- return m("googleMapsMap", o), this.createMap(r, a.value).then((n) => {
136
- o.value = n, c(a, () => {
137
- console.error("Cannot update options (missing function similar to deckglMap.setProps()). Use SDK dedicated functions instead");
138
- }, { once: !0 }), s("loaded", n);
139
- }), () => v("div", { ref: r }, o.value ? t : []);
140
- },
141
- {
142
- props: {
143
- options: {
144
- type: Object,
145
- default: () => ({})
146
- }
147
- },
148
- emits: ["loaded"]
149
- }
150
- );
151
- }
152
- get Map3D() {
153
- return p(
154
- (e, { emit: s, attrs: t, slots: r }) => {
155
- const a = y(null), { options: o, layers: n } = u(e), i = g(null);
156
- return m("googleMapsMap3D", i), this.createMap3D(a, o.value).then((h) => {
157
- i.value = h, h.watchOptions(o, o.value.watchOptionsOptions), h.watchLayers(n, o.value.watchLayersOptions), s("loaded", h);
158
- }), () => v("div", { ref: a }, i.value ? r : []);
159
- },
160
- {
161
- props: {
162
- options: {
163
- type: Object,
164
- default: () => ({})
165
- },
166
- layers: {
167
- type: Array,
168
- default: () => []
169
- }
170
- },
171
- emits: ["loaded"]
172
- }
173
- );
174
- }
175
- get DeckGLOverlay() {
176
- return p(
177
- (e, { emit: s, slots: t }) => {
178
- const { options: r, layers: a } = u(e), o = f("googleMapsMap");
179
- if (!o || !o.value)
180
- throw new Error("map should exist");
181
- return o.value.setDeckGLOverlay(r.value).then((n) => {
182
- n.watchOptions(r, r.value.watchOptionsOptions), n.watchLayers(a, r.value.watchLayersOptions), s("loaded", n);
183
- }), () => {
184
- };
185
- },
186
- {
187
- props: {
188
- options: {
189
- type: Object,
190
- default: () => ({})
191
- },
192
- layers: {
193
- type: Array,
194
- default: () => []
195
- }
196
- },
197
- emits: ["loaded"]
198
- }
199
- );
200
- }
201
- get DeckGL3DTileLayer() {
202
- return p(
203
- (e, { emit: s, slots: t }) => {
204
- const { options: r } = u(e), a = f("deckGLPrependLayers");
205
- if (!a || !a.value)
206
- throw new Error("deckGLPrependLayers should exist");
207
- const o = y("");
208
- this.createDeckGL3DTileLayer(o, r.value).then((i) => {
209
- c(r, () => {
210
- console.error("Cannot update options on DeckGL layer. Replace layer instead");
211
- }, { once: !0 }), a.value = [
212
- ...a.value,
213
- i
214
- ];
215
- });
216
- const n = f("deckGLAppendVNodeFn");
217
- if (!n)
218
- throw new Error("deckGLAppendVNodeFn should exist");
219
- return t.appendMap && n.value.push(() => t.appendMap({ credits: o.value })), () => {
220
- };
221
- },
222
- {
223
- props: {
224
- options: {
225
- type: Object,
226
- default: () => ({})
227
- }
228
- }
229
- }
230
- );
231
- }
232
- async loadGoogleMapsSDK({ libraries: e = [] } = {}) {
233
- const { Loader: s } = await import("@googlemaps/js-api-loader"), t = [.../* @__PURE__ */ new Set([...this.libraries, ...e])];
234
- this.libraries.length === t.length && this.libraries.every((a) => t.includes(a)) || console.error("GoogleMaps Loader does not allow loading one library after the other. Set libraries option on a single googleMaps config"), this.libraries = t, this.loader = new s({
235
- apiKey: this.apiKey,
236
- version: this.version,
237
- libraries: this.libraries
238
- });
239
- const r = await Promise.all(this.libraries.map((a) => this.sdk[a] || this.loader.importLibrary(a)));
240
- for (const [a, o] of this.libraries.entries())
241
- this.sdk[o] = r[a];
242
- }
243
- async getSDK(e) {
244
- let s = {};
245
- if (typeof e == "string" ? s.libraries = [e] : s = { ...e }, await this.loadGoogleMapsSDK(s), typeof e == "string") {
246
- if (!this.sdk[e] || !Object.keys(this.sdk[e]).length)
247
- throw new Error(`${e} library is not loaded${e === "maps3d" ? ". Missing version: 'alpha' or apiKey not authorized?" : ""}`);
248
- return this.sdk[e];
249
- }
250
- return this.sdk;
251
- }
252
- async createMap(e, s = {}) {
253
- const t = new G(), r = () => {
254
- for (const a of t.unwatchFn)
255
- a();
256
- t.unwatchFn = [], t.map && (t.map = null);
257
- };
258
- return new Promise((a, o) => {
259
- L(async () => {
260
- await this.getSDK("maps");
261
- const n = () => {
262
- if (!e.value)
263
- throw new Error("Missing HTML element");
264
- const i = c(e, () => {
265
- e.value || (r(), i());
266
- });
267
- t.map = new this.sdk.maps.Map(e.value, {
268
- ...s
269
- }), a(t);
270
- };
271
- s.onMounted ? s.onMounted(n) : n();
272
- }), M(() => {
273
- r();
274
- });
275
- });
276
- }
277
- async createMap3D(e, s = {}) {
278
- const t = new D(), r = () => {
279
- for (const a of t.unwatchFn)
280
- a();
281
- t.unwatchFn = [], t.map && (t.map = null);
282
- };
283
- return new Promise((a, o) => {
284
- L(async () => {
285
- await this.getSDK("maps3d");
286
- const n = () => {
287
- if (!e.value)
288
- throw new Error("Missing HTML element");
289
- const i = c(e, () => {
290
- e.value || (r(), i());
291
- });
292
- t.map = new this.sdk.maps3d.Map3DElement({
293
- ...s
294
- }), e.value.appendChild(t.map), a(t);
295
- };
296
- s.onMounted ? s.onMounted(n) : n();
297
- }), M(() => {
298
- r();
299
- });
300
- });
301
- }
302
- async loadDeckGL() {
303
- const { Tile3DLayer: e } = await import("deck.gl");
304
- this.deckgl = { Tile3DLayer: e };
305
- }
306
- async createDeckGL3DTileLayer(e, s = {}) {
307
- return await (this.deckgl ? Promise.resolve() : this.loadDeckGL()), new this.deckgl.Tile3DLayer({
308
- id: "google-3d-tiles",
309
- data: "https://tile.googleapis.com/v1/3dtiles/root.json",
310
- loadOptions: {
311
- fetch: {
312
- headers: {
313
- "X-GOOG-API-KEY": this.apiKey
314
- }
315
- }
316
- },
317
- onTilesetLoad: (t) => {
318
- e && (t.options.onTraversalComplete = (r) => {
319
- const a = /* @__PURE__ */ new Set();
320
- return r.forEach((o) => {
321
- const { copyright: n } = o.content.gltf.asset;
322
- n.split(";").forEach(a.add, a), e.value = [...a].join("; ");
323
- }), r;
324
- });
325
- },
326
- operation: "terrain+draw",
327
- ...s
328
- });
329
- }
330
- }
331
- export {
332
- F as default
1
+ import { DeckGLOverlay as e, makeDeckGLOverlayComponent as t } from "../DeckGLOverlay.js";
2
+ import { isString as n } from "lodash-es";
3
+ import { defineComponent as r, h as i, inject as a, nextTick as o, onMounted as s, onUnmounted as c, provide as l, ref as u, shallowRef as d, toRaw as f, toRefs as p, watch as m } from "vue";
4
+ var h = class extends e {
5
+ _detach() {
6
+ this.overlay.setMap(null), this.overlay.finalize();
7
+ }
8
+ }, g = class {
9
+ constructor() {
10
+ this.map = null, this.unwatchFn = [], this.overlays = [];
11
+ }
12
+ async setDeckGLOverlay(e = {}) {
13
+ if (!this.map) throw Error("map should be set");
14
+ let { GoogleMapsOverlay: t } = await import("@deck.gl/google-maps"), n = new h({
15
+ unwatchFn: [],
16
+ trackedIn: this.overlays
17
+ });
18
+ return n.overlay = new t(e), n.overlay.setMap(this.map), this.overlays.push(n), n;
19
+ }
20
+ }, _ = class {
21
+ constructor() {
22
+ this.map = null, this.watching = {
23
+ options: !1,
24
+ layers: !1
25
+ }, this.unwatchFn = [];
26
+ }
27
+ _getSetters(e) {
28
+ let t = [], n = { ...Object.getOwnPropertyDescriptors(Object.getPrototypeOf(e)) };
29
+ for (let [e, r] of Object.entries(n)) r.enumerable && (r.get || r.set) && t.push(e);
30
+ return t;
31
+ }
32
+ _getOptions(e, t = /* @__PURE__ */ new WeakSet()) {
33
+ let n = {};
34
+ t.add(e);
35
+ let r = this._getSetters(e);
36
+ for (let i of r) {
37
+ let r = e[i];
38
+ r instanceof Object && !t.has(r) && this._getSetters(r).length && (r = this._getOptions(r, t)), n[i] = r;
39
+ }
40
+ return n;
41
+ }
42
+ setProps(e = {}) {
43
+ if (!this.map) throw Error("map should be set");
44
+ for (let [t, n] of Object.entries(e)) this.map[t] = n;
45
+ }
46
+ getProps() {
47
+ if (!this.map) throw Error("map should be set");
48
+ return this._getOptions(this.map);
49
+ }
50
+ getLayer(e) {
51
+ if (!this.map) throw Error("map should be set");
52
+ return this.map.children.namedItem(e);
53
+ }
54
+ watchOptions(e, t = {}) {
55
+ if (!this.map) throw Error("map should be set");
56
+ if (this.watching.options) {
57
+ console.warn("No need to call GoogleMapsMap3D.watchOptions(). options are already being watched");
58
+ return;
59
+ }
60
+ this.watching.options = !0;
61
+ let n = {}, r = m(e, async () => {
62
+ await o();
63
+ let t = f(e.value), r = {};
64
+ for (let [e, i] of Object.entries(t)) r[e] = JSON.stringify(i), r[e] !== n[e] && (this.map[e] = i);
65
+ n = r;
66
+ }, {
67
+ immediate: !0,
68
+ deep: !0,
69
+ ...t
70
+ });
71
+ this.unwatchFn.push(r);
72
+ }
73
+ watchLayers(e, t = {}) {
74
+ if (!this.map) throw Error("map should be set");
75
+ if (this.watching.layers) {
76
+ console.warn("No need to call GoogleMapsMap3D.watchLayers(). layers are already being watched");
77
+ return;
78
+ }
79
+ this.watching.layers = !0;
80
+ let n = m(() => [...e.value || []], async (e, t) => {
81
+ let n = t || [], r = e || [], i = new Map(n.map((e) => [e.id, e])), a = new Map(r.map((e) => [e.id, e])), s = r.filter((e) => e !== i.get(e.id)), c = n.filter((e) => e !== a.get(e.id));
82
+ await o();
83
+ for (let e of c) this.map.children.namedItem(e.id).remove();
84
+ let l = new Set(s.map((e) => e.id));
85
+ for (let e = 0; e < r.length; e++) {
86
+ let t = r[e];
87
+ if (l.has(t.id)) {
88
+ t.element.setAttribute("name", t.id);
89
+ let n;
90
+ for (let t = e + 1; t < r.length; t++) if (!l.has(r[t].id)) {
91
+ n = r[t].id;
92
+ break;
93
+ }
94
+ this.map.insertBefore(t.element, n ? this.map.children.namedItem(n) : null);
95
+ }
96
+ }
97
+ }, {
98
+ immediate: !0,
99
+ ...t
100
+ });
101
+ this.unwatchFn.push(n);
102
+ }
103
+ }, v = class {
104
+ constructor(e) {
105
+ if (this.apiKey = e.apiKey, !this.apiKey) throw Error("apiKey is required");
106
+ this.libraries = [...e.libraries || []], this.version = e.version || "weekly", this._mapsApiConfigured = !1, this.authFailed = !1, this.sdk = {}, this.deckgl = null, this._MapComponent = null, this._Map3DComponent = null, this._DeckGLOverlayComponent = null, this._DeckGL3DTileLayerComponent = null, this.ready = this.getSDK(), this.ready.catch((e) => {
107
+ console.error(`${this.constructor.name} SDK preload failed`, e);
108
+ });
109
+ }
110
+ get Map() {
111
+ return this._MapComponent ??= r((e, { emit: t, slots: n }) => {
112
+ let r = u(null), { options: a } = p(e), o = d(null);
113
+ return l("googleMapsMap", o), this.createMap(r, a.value).then((e) => {
114
+ o.value = e, e.unwatchFn.push(m(a, () => {
115
+ console.error("Cannot update options (missing function similar to deckglMap.setProps()). Use SDK dedicated functions instead");
116
+ }, { once: !0 })), t("loaded", e);
117
+ }).catch((e) => {
118
+ e?.code !== "MAP_UNMOUNTED" && t("error", e);
119
+ }), () => i("div", { ref: r }, o.value ? n : []);
120
+ }, {
121
+ props: { options: {
122
+ type: Object,
123
+ default: () => ({})
124
+ } },
125
+ emits: ["loaded", "error"]
126
+ }), this._MapComponent;
127
+ }
128
+ get Map3D() {
129
+ return this._Map3DComponent ??= r((e, { emit: t, slots: n }) => {
130
+ let r = u(null), { options: a, layers: o } = p(e), s = d(null);
131
+ return l("googleMapsMap3D", s), this.createMap3D(r, a.value).then((e) => {
132
+ s.value = e, e.watchOptions(a, a.value.watchOptionsOptions), e.watchLayers(o, a.value.watchLayersOptions), t("loaded", e);
133
+ }).catch((e) => {
134
+ e?.code !== "MAP_UNMOUNTED" && t("error", e);
135
+ }), () => i("div", { ref: r }, s.value ? n : []);
136
+ }, {
137
+ props: {
138
+ options: {
139
+ type: Object,
140
+ default: () => ({})
141
+ },
142
+ layers: {
143
+ type: Array,
144
+ default: () => []
145
+ }
146
+ },
147
+ emits: ["loaded", "error"]
148
+ }), this._Map3DComponent;
149
+ }
150
+ get DeckGLOverlay() {
151
+ return this._DeckGLOverlayComponent ??= t("googleMapsMap"), this._DeckGLOverlayComponent;
152
+ }
153
+ get DeckGL3DTileLayer() {
154
+ return this._DeckGL3DTileLayerComponent ??= r((e, { slots: t, emit: n }) => {
155
+ let { options: r } = p(e), i = a("deckGLPrependLayers");
156
+ if (!i || !i.value) throw Error("deckGLPrependLayers should exist");
157
+ let o = u(""), s = null, l = !1, d = null;
158
+ this.createDeckGL3DTileLayer(o, r.value).then((e) => {
159
+ l || (s = e, d = m(r, () => {
160
+ console.error("Cannot update options on DeckGL layer. Replace layer instead");
161
+ }, { once: !0 }), i.value = [...i.value, e]);
162
+ }).catch((e) => {
163
+ l || n("error", e);
164
+ });
165
+ let f = a("deckGLAppendVNodeFn");
166
+ if (!f) throw Error("deckGLAppendVNodeFn should exist");
167
+ let h = t.appendMap ? () => t.appendMap({ credits: o.value }) : null;
168
+ return h && f.value.push(h), c(() => {
169
+ l = !0, d?.(), s &&= (i.value = i.value.filter((e) => e !== s), null), h && (f.value = f.value.filter((e) => e !== h));
170
+ }), () => {};
171
+ }, {
172
+ props: { options: {
173
+ type: Object,
174
+ default: () => ({})
175
+ } },
176
+ emits: ["error"]
177
+ }), this._DeckGL3DTileLayerComponent;
178
+ }
179
+ async loadGoogleMapsSDK({ libraries: e = [] } = {}) {
180
+ let { setOptions: t, importLibrary: n } = await import("@googlemaps/js-api-loader");
181
+ if (!this._mapsApiConfigured) {
182
+ if (t({
183
+ key: this.apiKey,
184
+ v: this.version
185
+ }), globalThis.window) {
186
+ let e = window.gm_authFailure;
187
+ window.gm_authFailure = (...t) => {
188
+ this.authFailed = !0, console.error("Google Maps authentication failed (invalid key or unauthorized referrer): rendered maps stay greyed. Check maps.<key>.apiKey and the key restrictions."), e?.(...t);
189
+ };
190
+ }
191
+ this._mapsApiConfigured = !0;
192
+ }
193
+ let r = [.../* @__PURE__ */ new Set([...this.libraries, ...e])], i = await Promise.all(r.map((e) => this.sdk[e] || n(e)));
194
+ for (let [e, t] of r.entries()) this.sdk[t] = i[e];
195
+ this.libraries = r;
196
+ }
197
+ async getSDK(e) {
198
+ let t = n(e), r = {};
199
+ if (t ? r.libraries = [e] : r = { ...e }, await this.loadGoogleMapsSDK(r), t) {
200
+ if (!this.sdk[e] || !Object.keys(this.sdk[e]).length) throw Error(`${e} library is not loaded${e === "maps3d" ? ". Missing version: 'alpha' or apiKey not authorized?" : ""}`);
201
+ return this.sdk[e];
202
+ }
203
+ return this.sdk;
204
+ }
205
+ async createMap(e, t = {}) {
206
+ if (this.authFailed) throw Error("Google Maps authentication already failed on this page (gm_authFailure): fix the API key / referrer restrictions before creating more maps.");
207
+ let n = new g(), r = () => {
208
+ for (let e of n.unwatchFn) e();
209
+ n.unwatchFn = [];
210
+ for (let e of [...n.overlays]) e.destroy();
211
+ n.overlays = [], n.map &&= (window.google?.maps?.event && window.google.maps.event.clearInstanceListeners(n.map), null);
212
+ };
213
+ return new Promise((i, a) => {
214
+ s(() => {
215
+ let o = () => {
216
+ if (!e.value) {
217
+ let e = /* @__PURE__ */ Error("Missing HTML element");
218
+ throw a(e), e;
219
+ }
220
+ let o = m(e, () => {
221
+ e.value || (r(), o());
222
+ });
223
+ n.map = new this.sdk.maps.Map(e.value, { ...t }), i(n);
224
+ };
225
+ (async () => {
226
+ await this.getSDK("maps"), t.onMounted ? t.onMounted(o) : o();
227
+ })().catch(a);
228
+ }), c(() => {
229
+ r();
230
+ let e = /* @__PURE__ */ Error("Map unmounted before load");
231
+ e.code = "MAP_UNMOUNTED", a(e);
232
+ });
233
+ });
234
+ }
235
+ async createMap3D(e, t = {}) {
236
+ if (this.authFailed) throw Error("Google Maps authentication already failed on this page (gm_authFailure): fix the API key / referrer restrictions before creating more maps.");
237
+ let n = new _(), r = () => {
238
+ for (let e of n.unwatchFn) e();
239
+ n.unwatchFn = [], n.map &&= (n.map.remove(), null);
240
+ };
241
+ return new Promise((i, a) => {
242
+ s(() => {
243
+ let o = () => {
244
+ if (!e.value) {
245
+ let e = /* @__PURE__ */ Error("Missing HTML element");
246
+ throw a(e), e;
247
+ }
248
+ let o = m(e, () => {
249
+ e.value || (r(), o());
250
+ });
251
+ n.map = new this.sdk.maps3d.Map3DElement({ ...t }), e.value.appendChild(n.map), i(n);
252
+ };
253
+ (async () => {
254
+ await this.getSDK("maps3d"), t.onMounted ? t.onMounted(o) : o();
255
+ })().catch(a);
256
+ }), c(() => {
257
+ r();
258
+ let e = /* @__PURE__ */ Error("Map unmounted before load");
259
+ e.code = "MAP_UNMOUNTED", a(e);
260
+ });
261
+ });
262
+ }
263
+ async loadDeckGL() {
264
+ let { Tile3DLayer: e } = await import("@deck.gl/geo-layers");
265
+ this.deckgl = { Tile3DLayer: e };
266
+ }
267
+ async createDeckGL3DTileLayer(e, t = {}) {
268
+ await (this.deckgl ? Promise.resolve() : this.loadDeckGL());
269
+ let { onTilesetLoad: n, ...r } = t;
270
+ return new this.deckgl.Tile3DLayer({
271
+ id: "google-3d-tiles",
272
+ data: "https://tile.googleapis.com/v1/3dtiles/root.json",
273
+ loadOptions: { fetch: { headers: { "X-GOOG-API-KEY": this.apiKey } } },
274
+ onTilesetLoad: (t) => {
275
+ t.options.onTraversalComplete = (t) => {
276
+ let n = /* @__PURE__ */ new Set();
277
+ return t.forEach((e) => {
278
+ let { copyright: t } = e.content.gltf.asset;
279
+ t.split(";").forEach(n.add, n);
280
+ }), e.value = [...n].join("; "), t;
281
+ }, n?.(t);
282
+ },
283
+ operation: "terrain+draw",
284
+ ...r
285
+ });
286
+ }
333
287
  };
288
+ export { v as default };