@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.
- package/lib/DeckGLOverlay.js +76 -0
- package/lib/providers/deckgl.js +111 -110
- package/lib/providers/google-maps.js +287 -332
- package/lib/providers/mapbox.js +230 -238
- package/lib/providers/maplibre.js +27 -244
- package/lib/searoute.js +38321 -59
- package/lib/types/main.d.ts +27 -0
- package/lib/types/providers/DeckGL.d.ts +10 -0
- package/lib/types/providers/DeckGLOverlay.d.ts +30 -0
- package/lib/types/providers/GoogleMaps.d.ts +41 -0
- package/lib/types/providers/Mapbox.d.ts +114 -0
- package/lib/types/providers/Maplibre.d.ts +13 -0
- package/lib/types/searoute/searoute.d.ts +1 -0
- package/lib/types/utils/getAirRoute.d.ts +6 -0
- package/lib/types/utils/getWaterRoute.d.ts +6 -0
- package/lib/types/utils/normalizeRoute.d.ts +1 -0
- package/lib/yappkit-map.js +60 -729
- package/package.json +21 -17
- package/lib/mapbox-gl.css +0 -1
- package/lib/mapbox-gl.js +0 -32271
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { defineComponent as e, inject as t, onUnmounted as n, toRefs as r, watch as i } from "vue";
|
|
2
|
+
var a = class {
|
|
3
|
+
constructor({ unwatchFn: e, trackedIn: t = null }) {
|
|
4
|
+
this.overlay = null, this.watching = {
|
|
5
|
+
options: !1,
|
|
6
|
+
layers: !1
|
|
7
|
+
}, this.unwatchFn = e, this.trackedIn = t;
|
|
8
|
+
}
|
|
9
|
+
destroy() {
|
|
10
|
+
if (this.trackedIn) {
|
|
11
|
+
let e = this.trackedIn.indexOf(this);
|
|
12
|
+
e !== -1 && this.trackedIn.splice(e, 1), this.trackedIn = null;
|
|
13
|
+
}
|
|
14
|
+
for (let e of this.unwatchFn) e();
|
|
15
|
+
this.unwatchFn = [], this.overlay &&= (this._detach(), null);
|
|
16
|
+
}
|
|
17
|
+
watchOptions(e, t = {}) {
|
|
18
|
+
if (!this.overlay) throw Error("overlay should be set");
|
|
19
|
+
if (this.watching.options) {
|
|
20
|
+
console.warn(`No need to call ${this.constructor.name}.watchOptions(). options are already being watched`);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
this.watching.options = !0;
|
|
24
|
+
let n = i(e, () => {
|
|
25
|
+
this.overlay.setProps({ ...e.value });
|
|
26
|
+
}, {
|
|
27
|
+
immediate: !0,
|
|
28
|
+
deep: !0,
|
|
29
|
+
...t
|
|
30
|
+
});
|
|
31
|
+
this.unwatchFn.push(n);
|
|
32
|
+
}
|
|
33
|
+
watchLayers(e, t = {}) {
|
|
34
|
+
if (!this.overlay) throw Error("overlay should be set");
|
|
35
|
+
if (this.watching.layers) {
|
|
36
|
+
console.warn(`No need to call ${this.constructor.name}.watchLayers(). layers are already being watched`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
this.watching.layers = !0;
|
|
40
|
+
let n = i(e, () => {
|
|
41
|
+
this.overlay.setProps({ layers: e.value });
|
|
42
|
+
}, {
|
|
43
|
+
immediate: !0,
|
|
44
|
+
...t
|
|
45
|
+
});
|
|
46
|
+
this.unwatchFn.push(n);
|
|
47
|
+
}
|
|
48
|
+
}, o = (i) => e((e, { emit: a }) => {
|
|
49
|
+
let { options: o, layers: s } = r(e), c = t(i);
|
|
50
|
+
if (!c || !c.value) throw Error("map should exist");
|
|
51
|
+
let l = null, u = !1;
|
|
52
|
+
return c.value.setDeckGLOverlay(o.value).then((e) => {
|
|
53
|
+
if (u) {
|
|
54
|
+
e.destroy();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
l = e, e.watchOptions(o, o.value.watchOptionsOptions), e.watchLayers(s, o.value.watchLayersOptions), a("loaded", e);
|
|
58
|
+
}).catch((e) => {
|
|
59
|
+
u || a("error", e);
|
|
60
|
+
}), n(() => {
|
|
61
|
+
u = !0, l?.destroy();
|
|
62
|
+
}), () => {};
|
|
63
|
+
}, {
|
|
64
|
+
props: {
|
|
65
|
+
options: {
|
|
66
|
+
type: Object,
|
|
67
|
+
default: () => ({})
|
|
68
|
+
},
|
|
69
|
+
layers: {
|
|
70
|
+
type: Array,
|
|
71
|
+
default: () => []
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
emits: ["loaded", "error"]
|
|
75
|
+
});
|
|
76
|
+
export { a as DeckGLOverlay, o as makeDeckGLOverlayComponent };
|
package/lib/providers/deckgl.js
CHANGED
|
@@ -1,111 +1,112 @@
|
|
|
1
|
-
import {
|
|
2
|
-
class
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
class
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
1
|
+
import { computed as e, defineComponent as t, h as n, onMounted as r, onUnmounted as i, provide as a, ref as o, shallowRef as s, toRefs as c, watch as l } from "vue";
|
|
2
|
+
var u = class {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.map = null, this.watching = {
|
|
5
|
+
options: !1,
|
|
6
|
+
layers: !1
|
|
7
|
+
}, this.unwatchFn = [];
|
|
8
|
+
}
|
|
9
|
+
watchOptions(e, t = {}) {
|
|
10
|
+
if (!this.map) throw Error("map should be set");
|
|
11
|
+
if (this.watching.options) {
|
|
12
|
+
console.warn("No need to call DeckGLMap.watchOptions(). options are already being watched");
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
this.watching.options = !0;
|
|
16
|
+
let n = l(e, () => {
|
|
17
|
+
this.map.setProps({ ...e.value });
|
|
18
|
+
}, {
|
|
19
|
+
immediate: !0,
|
|
20
|
+
deep: !0,
|
|
21
|
+
...t
|
|
22
|
+
});
|
|
23
|
+
this.unwatchFn.push(n);
|
|
24
|
+
}
|
|
25
|
+
watchLayers(e, t = {}) {
|
|
26
|
+
if (!this.map) throw Error("map should be set");
|
|
27
|
+
if (this.watching.layers) {
|
|
28
|
+
console.warn("No need to call DeckGLMap.watchLayers(). layers are already being watched");
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
this.watching.layers = !0;
|
|
32
|
+
let n = l(e, () => {
|
|
33
|
+
this.map.setProps({ layers: e.value });
|
|
34
|
+
}, {
|
|
35
|
+
immediate: !0,
|
|
36
|
+
...t
|
|
37
|
+
});
|
|
38
|
+
this.unwatchFn.push(n);
|
|
39
|
+
}
|
|
40
|
+
}, d = class {
|
|
41
|
+
constructor() {
|
|
42
|
+
this.deckgl = null, this._MapComponent = null;
|
|
43
|
+
}
|
|
44
|
+
get Map() {
|
|
45
|
+
return this._MapComponent ??= t((t, { emit: r, attrs: i, slots: l }) => {
|
|
46
|
+
let u = o(null), { options: d, layers: f } = c(t), p = s(null);
|
|
47
|
+
a("deckGLMap", p);
|
|
48
|
+
let m = s([]);
|
|
49
|
+
a("deckGLPrependLayers", m);
|
|
50
|
+
let h = e(() => [...m.value, ...f.value]);
|
|
51
|
+
this.createMap(u, d.value).then((e) => {
|
|
52
|
+
p.value = e, e.watchOptions(d, d.value.watchOptionsOptions), e.watchLayers(h, d.value.watchLayersOptions), r("loaded", e);
|
|
53
|
+
}).catch((e) => {
|
|
54
|
+
e?.code !== "MAP_UNMOUNTED" && r("error", e);
|
|
55
|
+
});
|
|
56
|
+
let g = o([]);
|
|
57
|
+
return a("deckGLAppendVNodeFn", g), () => [n("div", {
|
|
58
|
+
...i,
|
|
59
|
+
ref: u
|
|
60
|
+
}, p.value ? l : []), g.value.map((e) => e())];
|
|
61
|
+
}, {
|
|
62
|
+
props: {
|
|
63
|
+
options: {
|
|
64
|
+
type: Object,
|
|
65
|
+
default: () => ({})
|
|
66
|
+
},
|
|
67
|
+
layers: {
|
|
68
|
+
type: Array,
|
|
69
|
+
default: () => []
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
emits: ["loaded", "error"]
|
|
73
|
+
}), this._MapComponent;
|
|
74
|
+
}
|
|
75
|
+
async loadDeckGL() {
|
|
76
|
+
if (!this.deckgl) {
|
|
77
|
+
let { Deck: e } = await import("@deck.gl/core");
|
|
78
|
+
this.deckgl = { Deck: e };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async createMap(e, t = {}) {
|
|
82
|
+
let n = new u(), a = () => {
|
|
83
|
+
for (let e of n.unwatchFn) e();
|
|
84
|
+
n.unwatchFn = [], n.map &&= (n.map.finalize(), null);
|
|
85
|
+
};
|
|
86
|
+
return new Promise((o, s) => {
|
|
87
|
+
r(() => {
|
|
88
|
+
let r = () => {
|
|
89
|
+
if (!e.value) {
|
|
90
|
+
let e = /* @__PURE__ */ Error("Missing HTML element");
|
|
91
|
+
throw s(e), e;
|
|
92
|
+
}
|
|
93
|
+
let r = l(e, () => {
|
|
94
|
+
e.value || (a(), r());
|
|
95
|
+
});
|
|
96
|
+
n.map = new this.deckgl.Deck({
|
|
97
|
+
parent: e.value,
|
|
98
|
+
...t
|
|
99
|
+
}), o(n);
|
|
100
|
+
};
|
|
101
|
+
(async () => {
|
|
102
|
+
await this.loadDeckGL(), t.onMounted ? t.onMounted(r) : r();
|
|
103
|
+
})().catch(s);
|
|
104
|
+
}), i(() => {
|
|
105
|
+
a();
|
|
106
|
+
let e = /* @__PURE__ */ Error("Map unmounted before load");
|
|
107
|
+
e.code = "MAP_UNMOUNTED", s(e);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
111
|
};
|
|
112
|
+
export { d as default };
|