@yappkit/front-module-map 0.1.0 → 0.1.2
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/providers/mapbox.js +67 -67
- package/lib/providers/maplibre.js +69 -69
- package/lib/searoute.js +6 -6
- package/lib/yappkit-map.js +62 -63
- package/package.json +5 -9
- package/lib/_commonjsHelpers.js +0 -8
- package/lib/mapbox-gl.css +0 -1
- package/lib/mapbox-gl.js +0 -30200
- package/lib/mapbox-sdk/browser-client.js +0 -500
- package/lib/mapbox-sdk/create-service-factory.js +0 -237
- package/lib/mapbox-sdk/datasets.js +0 -123
- package/lib/mapbox-sdk/directions.js +0 -155
- package/lib/mapbox-sdk/geocoding-v6.js +0 -129
- package/lib/mapbox-sdk/geocoding.js +0 -113
- package/lib/mapbox-sdk/isochrone.js +0 -82
- package/lib/mapbox-sdk/map-matching.js +0 -110
- package/lib/mapbox-sdk/matrix.js +0 -72
- package/lib/mapbox-sdk/object-clean.js +0 -11
- package/lib/mapbox-sdk/optimization.js +0 -106
- package/lib/mapbox-sdk/static.js +0 -197
- package/lib/mapbox-sdk/stringify-booleans.js +0 -15
- package/lib/mapbox-sdk/styles.js +0 -181
- package/lib/mapbox-sdk/tilequery.js +0 -46
- package/lib/mapbox-sdk/tilesets.js +0 -214
- package/lib/mapbox-sdk/tokens.js +0 -111
- package/lib/mapbox-sdk/uploads.js +0 -77
- package/lib/mapbox-sdk.js +0 -26
package/lib/providers/mapbox.js
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import { defineComponent as m, ref as f, toRefs as y, shallowRef as v, provide as b, h as g, inject as x, onMounted as M, onUnmounted as L, watch as
|
|
1
|
+
import { defineComponent as m, ref as f, toRefs as y, shallowRef as v, provide as b, h as g, inject as x, onMounted as M, onUnmounted as L, watch as d, nextTick as w } from "vue";
|
|
2
2
|
class S {
|
|
3
3
|
constructor() {
|
|
4
4
|
this.overlay = null, this.watching = { layers: !1 };
|
|
5
5
|
}
|
|
6
|
-
watchLayers(
|
|
6
|
+
watchLayers(t, a = {}) {
|
|
7
7
|
if (!this.overlay)
|
|
8
8
|
throw new Error("overlay should be set");
|
|
9
9
|
if (this.watching.layers) {
|
|
10
10
|
console.warn("No need to call MapboxDeckGLOverlay.watchLayers(). layers are already being watched");
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
|
-
this.watching.layers = !0,
|
|
14
|
-
this.overlay.setProps({ layers:
|
|
15
|
-
},
|
|
13
|
+
this.watching.layers = !0, d(t, () => {
|
|
14
|
+
this.overlay.setProps({ layers: t.value });
|
|
15
|
+
}, a);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
class k {
|
|
19
19
|
constructor() {
|
|
20
20
|
this.map = null, this.watching = { sources: !1, layers: !1 };
|
|
21
21
|
}
|
|
22
|
-
watchSources(
|
|
22
|
+
watchSources(t, a = {}) {
|
|
23
23
|
if (!this.map)
|
|
24
24
|
throw new Error("map should be set");
|
|
25
25
|
if (this.watching.sources) {
|
|
26
26
|
console.warn("No need to call MapboxMap.watchSources(). sources are already being watched");
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
this.watching.sources = !0,
|
|
30
|
-
const
|
|
31
|
-
for (const
|
|
29
|
+
this.watching.sources = !0, d(t, (s, r) => {
|
|
30
|
+
const o = [...r || []], i = [...s || []], n = i.map((e) => e.id), l = o.map((e) => e.id), c = i.filter((e) => !l.includes(e.id)), p = o.filter((e) => !n.includes(e.id));
|
|
31
|
+
for (const e of p)
|
|
32
32
|
w(() => {
|
|
33
|
-
this.map.removeSource(
|
|
33
|
+
this.map.removeSource(e.id);
|
|
34
34
|
});
|
|
35
|
-
for (const
|
|
36
|
-
const u = { ...
|
|
37
|
-
delete u.id, this.map.addSource(
|
|
35
|
+
for (const e of c) {
|
|
36
|
+
const u = { ...e };
|
|
37
|
+
delete u.id, this.map.addSource(e.id, u);
|
|
38
38
|
}
|
|
39
|
-
},
|
|
39
|
+
}, a);
|
|
40
40
|
}
|
|
41
|
-
watchLayers(
|
|
41
|
+
watchLayers(t, a = {}) {
|
|
42
42
|
if (!this.map)
|
|
43
43
|
throw new Error("map should be set");
|
|
44
44
|
if (this.watching.layers) {
|
|
45
45
|
console.warn("No need to call MapboxMap.watchLayers(). layers are already being watched");
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
-
this.watching.layers = !0,
|
|
49
|
-
const
|
|
50
|
-
for (const
|
|
51
|
-
this.map.removeLayer(
|
|
52
|
-
for (const
|
|
48
|
+
this.watching.layers = !0, d(t, (s, r) => {
|
|
49
|
+
const o = [...r || []], i = [...s || []], n = i.map((e) => e.id), l = o.map((e) => e.id), c = i.filter((e) => !l.includes(e.id)), p = o.filter((e) => !n.includes(e.id));
|
|
50
|
+
for (const e of p)
|
|
51
|
+
this.map.removeLayer(e.id);
|
|
52
|
+
for (const e of c)
|
|
53
53
|
w(() => {
|
|
54
|
-
this.map.addLayer(
|
|
54
|
+
this.map.addLayer(e);
|
|
55
55
|
});
|
|
56
|
-
},
|
|
56
|
+
}, a);
|
|
57
57
|
}
|
|
58
|
-
async setDeckGLOverlay(
|
|
58
|
+
async setDeckGLOverlay(t = {}) {
|
|
59
59
|
if (!this.map)
|
|
60
60
|
throw new Error("map should be set");
|
|
61
|
-
const { MapboxOverlay:
|
|
62
|
-
return
|
|
61
|
+
const { MapboxOverlay: a } = await import("@deck.gl/mapbox"), s = new S();
|
|
62
|
+
return s.overlay = new a(t), this.map.addControl(s.overlay), s;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
class D {
|
|
66
|
-
constructor(
|
|
67
|
-
if (this.apiKey =
|
|
66
|
+
constructor(t) {
|
|
67
|
+
if (this.apiKey = t.apiKey, !this.apiKey)
|
|
68
68
|
throw new Error("apiKey is required");
|
|
69
|
-
this.services =
|
|
69
|
+
this.services = t.services || [], this.sdk = {}, this.mapboxgl = null, this.services.length && this.loadMapboxSDK();
|
|
70
70
|
}
|
|
71
71
|
get Map() {
|
|
72
72
|
return m(
|
|
73
|
-
(
|
|
74
|
-
const
|
|
75
|
-
return b("mapboxMap", l), this.createMap(
|
|
76
|
-
l.value = c, c.watchSources(n,
|
|
77
|
-
}), () => g("div", { ref:
|
|
73
|
+
(t, { emit: a, slots: s }) => {
|
|
74
|
+
const r = f(null), { options: o, layers: i, sources: n } = y(t), l = v(null);
|
|
75
|
+
return b("mapboxMap", l), this.createMap(r, o.value).then((c) => {
|
|
76
|
+
l.value = c, c.watchSources(n, o.value.watchSourcesOptions || { immediate: !0 }), c.watchLayers(i, o.value.watchLayersOptions || { immediate: !0 }), a("loaded", c);
|
|
77
|
+
}), () => g("div", { ref: r }, l.value ? s : []);
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
80
|
props: {
|
|
@@ -96,12 +96,12 @@ class D {
|
|
|
96
96
|
}
|
|
97
97
|
get DeckGLOverlay() {
|
|
98
98
|
return m(
|
|
99
|
-
(
|
|
100
|
-
const { options:
|
|
99
|
+
(t, { emit: a, slots: s }) => {
|
|
100
|
+
const { options: r, layers: o } = y(t), i = x("mapboxMap");
|
|
101
101
|
if (!i || !i.value)
|
|
102
102
|
throw new Error("map should exist");
|
|
103
|
-
return i.value.setDeckGLOverlay(
|
|
104
|
-
n.watchLayers(
|
|
103
|
+
return i.value.setDeckGLOverlay(r.value).then((n) => {
|
|
104
|
+
n.watchLayers(o, r.value.watchLayersOptions || { immediate: !0 }), a("loaded", n);
|
|
105
105
|
}), () => {
|
|
106
106
|
};
|
|
107
107
|
},
|
|
@@ -120,54 +120,54 @@ class D {
|
|
|
120
120
|
);
|
|
121
121
|
}
|
|
122
122
|
async loadMapbox() {
|
|
123
|
-
const
|
|
124
|
-
this.mapboxgl =
|
|
123
|
+
const t = await import("mapbox-gl");
|
|
124
|
+
this.mapboxgl = t;
|
|
125
125
|
}
|
|
126
126
|
get servicesLoader() {
|
|
127
127
|
return {
|
|
128
|
-
datasets: () => import("
|
|
129
|
-
directions: () => import("
|
|
130
|
-
geocoding: () => import("
|
|
131
|
-
geocodingV6: () => import("
|
|
132
|
-
mapMatching: () => import("
|
|
133
|
-
matrix: () => import("
|
|
134
|
-
optimization: () => import("
|
|
135
|
-
static: () => import("
|
|
136
|
-
styles: () => import("
|
|
137
|
-
tilequery: () => import("
|
|
138
|
-
tilesets: () => import("
|
|
139
|
-
tokens: () => import("
|
|
140
|
-
uploads: () => import("
|
|
141
|
-
isochrone: () => import("
|
|
128
|
+
datasets: () => import("@mapbox/mapbox-sdk/services/datasets.js"),
|
|
129
|
+
directions: () => import("@mapbox/mapbox-sdk/services/directions.js"),
|
|
130
|
+
geocoding: () => import("@mapbox/mapbox-sdk/services/geocoding.js"),
|
|
131
|
+
geocodingV6: () => import("@mapbox/mapbox-sdk/services/geocoding-v6.js"),
|
|
132
|
+
mapMatching: () => import("@mapbox/mapbox-sdk/services/map-matching.js"),
|
|
133
|
+
matrix: () => import("@mapbox/mapbox-sdk/services/matrix.js"),
|
|
134
|
+
optimization: () => import("@mapbox/mapbox-sdk/services/optimization.js"),
|
|
135
|
+
static: () => import("@mapbox/mapbox-sdk/services/static.js"),
|
|
136
|
+
styles: () => import("@mapbox/mapbox-sdk/services/styles.js"),
|
|
137
|
+
tilequery: () => import("@mapbox/mapbox-sdk/services/tilequery.js"),
|
|
138
|
+
tilesets: () => import("@mapbox/mapbox-sdk/services/tilesets.js"),
|
|
139
|
+
tokens: () => import("@mapbox/mapbox-sdk/services/tokens.js"),
|
|
140
|
+
uploads: () => import("@mapbox/mapbox-sdk/services/uploads.js"),
|
|
141
|
+
isochrone: () => import("@mapbox/mapbox-sdk/services/isochrone.js")
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
144
|
async loadMapboxSDK() {
|
|
145
|
-
const
|
|
146
|
-
for (const [
|
|
147
|
-
this.sdk[
|
|
145
|
+
const a = (await import("@mapbox/mapbox-sdk")).default({ accessToken: this.apiKey }), s = await Promise.all(this.services.map((r) => this.servicesLoader[r]().then((o) => o.default(a))));
|
|
146
|
+
for (const [r, o] of this.services.entries())
|
|
147
|
+
this.sdk[o] = s[r];
|
|
148
148
|
}
|
|
149
149
|
async getSDK() {
|
|
150
150
|
return await (Object.keys(this.sdk).length ? Promise.resolve() : this.loadMapboxSDK()), this.sdk;
|
|
151
151
|
}
|
|
152
|
-
async createMap(
|
|
153
|
-
const
|
|
154
|
-
return new Promise((
|
|
152
|
+
async createMap(t, a = {}) {
|
|
153
|
+
const s = new k();
|
|
154
|
+
return new Promise((r, o) => {
|
|
155
155
|
M(async () => {
|
|
156
156
|
await (this.mapboxgl ? Promise.resolve() : this.loadMapbox());
|
|
157
157
|
const i = () => {
|
|
158
|
-
if (!
|
|
158
|
+
if (!t.value)
|
|
159
159
|
throw new Error("Missing HTML element");
|
|
160
|
-
|
|
161
|
-
container:
|
|
160
|
+
s.map = new this.mapboxgl.Map({
|
|
161
|
+
container: t.value,
|
|
162
162
|
accessToken: this.apiKey,
|
|
163
|
-
...
|
|
164
|
-
}),
|
|
165
|
-
|
|
163
|
+
...a
|
|
164
|
+
}), s.map.on("load", () => {
|
|
165
|
+
r(s);
|
|
166
166
|
});
|
|
167
167
|
};
|
|
168
|
-
|
|
168
|
+
a.onMounted ? a.onMounted(i) : i();
|
|
169
169
|
}), L(() => {
|
|
170
|
-
|
|
170
|
+
s.map && (s.map.remove(), s.map = null);
|
|
171
171
|
});
|
|
172
172
|
});
|
|
173
173
|
}
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import { defineComponent as m, ref as f, toRefs as y, shallowRef as v, provide as b, h as
|
|
1
|
+
import { defineComponent as m, ref as f, toRefs as y, shallowRef as v, provide as b, h as x, inject as g, onMounted as M, onUnmounted as L, watch as h, nextTick as w } from "vue";
|
|
2
2
|
class S {
|
|
3
3
|
constructor() {
|
|
4
4
|
this.overlay = null, this.watching = { layers: !1 };
|
|
5
5
|
}
|
|
6
|
-
watchLayers(
|
|
6
|
+
watchLayers(t, a = {}) {
|
|
7
7
|
if (!this.overlay)
|
|
8
8
|
throw new Error("overlay should be set");
|
|
9
9
|
if (this.watching.layers) {
|
|
10
10
|
console.warn("No need to call MapboxDeckGLOverlay.watchLayers(). layers are already being watched");
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
|
-
this.watching.layers = !0,
|
|
14
|
-
this.overlay.setProps({ layers:
|
|
15
|
-
},
|
|
13
|
+
this.watching.layers = !0, h(t, () => {
|
|
14
|
+
this.overlay.setProps({ layers: t.value });
|
|
15
|
+
}, a);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
class k {
|
|
19
19
|
constructor() {
|
|
20
20
|
this.map = null, this.watching = { sources: !1, layers: !1 };
|
|
21
21
|
}
|
|
22
|
-
watchSources(
|
|
22
|
+
watchSources(t, a = {}) {
|
|
23
23
|
if (!this.map)
|
|
24
24
|
throw new Error("map should be set");
|
|
25
25
|
if (this.watching.sources) {
|
|
26
26
|
console.warn("No need to call MapboxMap.watchSources(). sources are already being watched");
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
this.watching.sources = !0,
|
|
30
|
-
const
|
|
31
|
-
for (const
|
|
29
|
+
this.watching.sources = !0, h(t, (s, r) => {
|
|
30
|
+
const o = [...r || []], i = [...s || []], n = i.map((e) => e.id), l = o.map((e) => e.id), c = i.filter((e) => !l.includes(e.id)), d = o.filter((e) => !n.includes(e.id));
|
|
31
|
+
for (const e of d)
|
|
32
32
|
w(() => {
|
|
33
|
-
this.map.removeSource(
|
|
33
|
+
this.map.removeSource(e.id);
|
|
34
34
|
});
|
|
35
|
-
for (const
|
|
36
|
-
const u = { ...
|
|
37
|
-
delete u.id, this.map.addSource(
|
|
35
|
+
for (const e of c) {
|
|
36
|
+
const u = { ...e };
|
|
37
|
+
delete u.id, this.map.addSource(e.id, u);
|
|
38
38
|
}
|
|
39
|
-
},
|
|
39
|
+
}, a);
|
|
40
40
|
}
|
|
41
|
-
watchLayers(
|
|
41
|
+
watchLayers(t, a = {}) {
|
|
42
42
|
if (!this.map)
|
|
43
43
|
throw new Error("map should be set");
|
|
44
44
|
if (this.watching.layers) {
|
|
45
45
|
console.warn("No need to call MapboxMap.watchLayers(). layers are already being watched");
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
-
this.watching.layers = !0,
|
|
49
|
-
const
|
|
50
|
-
for (const
|
|
51
|
-
this.map.removeLayer(
|
|
52
|
-
for (const
|
|
48
|
+
this.watching.layers = !0, h(t, (s, r) => {
|
|
49
|
+
const o = [...r || []], i = [...s || []], n = i.map((e) => e.id), l = o.map((e) => e.id), c = i.filter((e) => !l.includes(e.id)), d = o.filter((e) => !n.includes(e.id));
|
|
50
|
+
for (const e of d)
|
|
51
|
+
this.map.removeLayer(e.id);
|
|
52
|
+
for (const e of c)
|
|
53
53
|
w(() => {
|
|
54
|
-
this.map.addLayer(
|
|
54
|
+
this.map.addLayer(e);
|
|
55
55
|
});
|
|
56
|
-
},
|
|
56
|
+
}, a);
|
|
57
57
|
}
|
|
58
|
-
async setDeckGLOverlay(
|
|
58
|
+
async setDeckGLOverlay(t = {}) {
|
|
59
59
|
if (!this.map)
|
|
60
60
|
throw new Error("map should be set");
|
|
61
|
-
const { MapboxOverlay:
|
|
62
|
-
return
|
|
61
|
+
const { MapboxOverlay: a } = await import("@deck.gl/mapbox"), s = new S();
|
|
62
|
+
return s.overlay = new a(t), this.map.addControl(s.overlay), s;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
class O {
|
|
66
|
-
constructor(
|
|
67
|
-
if (this.apiKey =
|
|
66
|
+
constructor(t) {
|
|
67
|
+
if (this.apiKey = t.apiKey, !this.apiKey)
|
|
68
68
|
throw new Error("apiKey is required");
|
|
69
|
-
this.services =
|
|
69
|
+
this.services = t.services || [], this.sdk = {}, this.mapboxgl = null, this.services.length && this.loadMapboxSDK();
|
|
70
70
|
}
|
|
71
71
|
get Map() {
|
|
72
72
|
return m(
|
|
73
|
-
(
|
|
74
|
-
const
|
|
75
|
-
return b("mapboxMap", l), this.createMap(
|
|
76
|
-
l.value = c, c.watchSources(n,
|
|
77
|
-
}), () =>
|
|
73
|
+
(t, { emit: a, slots: s }) => {
|
|
74
|
+
const r = f(null), { options: o, layers: i, sources: n } = y(t), l = v(null);
|
|
75
|
+
return b("mapboxMap", l), this.createMap(r, o.value).then((c) => {
|
|
76
|
+
l.value = c, c.watchSources(n, o.value.watchSourcesOptions || { immediate: !0 }), c.watchLayers(i, o.value.watchLayersOptions || { immediate: !0 }), a("loaded", c);
|
|
77
|
+
}), () => x("div", { ref: r }, l.value ? s : []);
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
80
|
props: {
|
|
@@ -96,12 +96,12 @@ class O {
|
|
|
96
96
|
}
|
|
97
97
|
get DeckGLOverlay() {
|
|
98
98
|
return m(
|
|
99
|
-
(
|
|
100
|
-
const { options:
|
|
99
|
+
(t, { emit: a, slots: s }) => {
|
|
100
|
+
const { options: r, layers: o } = y(t), i = g("mapboxMap");
|
|
101
101
|
if (!i || !i.value)
|
|
102
102
|
throw new Error("map should exist");
|
|
103
|
-
return i.value.setDeckGLOverlay(
|
|
104
|
-
n.watchLayers(
|
|
103
|
+
return i.value.setDeckGLOverlay(r.value).then((n) => {
|
|
104
|
+
n.watchLayers(o, r.value.watchLayersOptions || { immediate: !0 }), a("loaded", n);
|
|
105
105
|
}), () => {
|
|
106
106
|
};
|
|
107
107
|
},
|
|
@@ -120,62 +120,62 @@ class O {
|
|
|
120
120
|
);
|
|
121
121
|
}
|
|
122
122
|
async loadMapbox() {
|
|
123
|
-
const
|
|
124
|
-
this.mapboxgl =
|
|
123
|
+
const t = await import("mapbox-gl");
|
|
124
|
+
this.mapboxgl = t;
|
|
125
125
|
}
|
|
126
126
|
get servicesLoader() {
|
|
127
127
|
return {
|
|
128
|
-
datasets: () => import("
|
|
129
|
-
directions: () => import("
|
|
130
|
-
geocoding: () => import("
|
|
131
|
-
geocodingV6: () => import("
|
|
132
|
-
mapMatching: () => import("
|
|
133
|
-
matrix: () => import("
|
|
134
|
-
optimization: () => import("
|
|
135
|
-
static: () => import("
|
|
136
|
-
styles: () => import("
|
|
137
|
-
tilequery: () => import("
|
|
138
|
-
tilesets: () => import("
|
|
139
|
-
tokens: () => import("
|
|
140
|
-
uploads: () => import("
|
|
141
|
-
isochrone: () => import("
|
|
128
|
+
datasets: () => import("@mapbox/mapbox-sdk/services/datasets.js"),
|
|
129
|
+
directions: () => import("@mapbox/mapbox-sdk/services/directions.js"),
|
|
130
|
+
geocoding: () => import("@mapbox/mapbox-sdk/services/geocoding.js"),
|
|
131
|
+
geocodingV6: () => import("@mapbox/mapbox-sdk/services/geocoding-v6.js"),
|
|
132
|
+
mapMatching: () => import("@mapbox/mapbox-sdk/services/map-matching.js"),
|
|
133
|
+
matrix: () => import("@mapbox/mapbox-sdk/services/matrix.js"),
|
|
134
|
+
optimization: () => import("@mapbox/mapbox-sdk/services/optimization.js"),
|
|
135
|
+
static: () => import("@mapbox/mapbox-sdk/services/static.js"),
|
|
136
|
+
styles: () => import("@mapbox/mapbox-sdk/services/styles.js"),
|
|
137
|
+
tilequery: () => import("@mapbox/mapbox-sdk/services/tilequery.js"),
|
|
138
|
+
tilesets: () => import("@mapbox/mapbox-sdk/services/tilesets.js"),
|
|
139
|
+
tokens: () => import("@mapbox/mapbox-sdk/services/tokens.js"),
|
|
140
|
+
uploads: () => import("@mapbox/mapbox-sdk/services/uploads.js"),
|
|
141
|
+
isochrone: () => import("@mapbox/mapbox-sdk/services/isochrone.js")
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
144
|
async loadMapboxSDK() {
|
|
145
|
-
const
|
|
146
|
-
for (const [
|
|
147
|
-
this.sdk[
|
|
145
|
+
const a = (await import("@mapbox/mapbox-sdk")).default({ accessToken: this.apiKey }), s = await Promise.all(this.services.map((r) => this.servicesLoader[r]().then((o) => o.default(a))));
|
|
146
|
+
for (const [r, o] of this.services.entries())
|
|
147
|
+
this.sdk[o] = s[r];
|
|
148
148
|
}
|
|
149
149
|
async getSDK() {
|
|
150
150
|
return await (Object.keys(this.sdk).length ? Promise.resolve() : this.loadMapboxSDK()), this.sdk;
|
|
151
151
|
}
|
|
152
|
-
async createMap(
|
|
153
|
-
const
|
|
154
|
-
return new Promise((
|
|
152
|
+
async createMap(t, a = {}) {
|
|
153
|
+
const s = new k();
|
|
154
|
+
return new Promise((r, o) => {
|
|
155
155
|
M(async () => {
|
|
156
156
|
await (this.mapboxgl ? Promise.resolve() : this.loadMapbox());
|
|
157
157
|
const i = () => {
|
|
158
|
-
if (!
|
|
158
|
+
if (!t.value)
|
|
159
159
|
throw new Error("Missing HTML element");
|
|
160
|
-
|
|
161
|
-
container:
|
|
160
|
+
s.map = new this.mapboxgl.Map({
|
|
161
|
+
container: t.value,
|
|
162
162
|
accessToken: this.apiKey,
|
|
163
|
-
...
|
|
164
|
-
}),
|
|
165
|
-
|
|
163
|
+
...a
|
|
164
|
+
}), s.map.on("load", () => {
|
|
165
|
+
r(s);
|
|
166
166
|
});
|
|
167
167
|
};
|
|
168
|
-
|
|
168
|
+
a.onMounted ? a.onMounted(i) : i();
|
|
169
169
|
}), L(() => {
|
|
170
|
-
|
|
170
|
+
s.map && (s.map.remove(), s.map = null);
|
|
171
171
|
});
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
class K extends O {
|
|
176
176
|
async loadMapbox() {
|
|
177
|
-
const
|
|
178
|
-
this.mapboxgl =
|
|
177
|
+
const t = await import("maplibre-gl");
|
|
178
|
+
this.mapboxgl = t;
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
export {
|
package/lib/searoute.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { featureEach as u, lineString as d, length as g, distance as m, pointToLineDistance as F, coordEach as S, rhumbDistance as L, point as f } from "@turf/turf";
|
|
2
2
|
import l from "geojson-path-finder";
|
|
3
3
|
const h = "FeatureCollection", w = "marnet_densified_", x = {
|
|
4
4
|
type: "name",
|
|
@@ -77404,7 +77404,7 @@ function E() {
|
|
|
77404
77404
|
}
|
|
77405
77405
|
function M(e, t) {
|
|
77406
77406
|
const r = e[0], p = t[0];
|
|
77407
|
-
return r === 180 && p === -180 || r === -180 && p === 180 ? 1 :
|
|
77407
|
+
return r === 180 && p === -180 || r === -180 && p === 180 ? 1 : m(e, t);
|
|
77408
77408
|
}
|
|
77409
77409
|
const T = new l(y, { weight: M });
|
|
77410
77410
|
function I(e, t, r = "nm") {
|
|
@@ -77422,15 +77422,15 @@ function c(e) {
|
|
|
77422
77422
|
u(y, function(n, i) {
|
|
77423
77423
|
const s = n.geometry.coordinates;
|
|
77424
77424
|
if (!k(s[0], s[1])) {
|
|
77425
|
-
const a =
|
|
77425
|
+
const a = F(e, n, { units: "kilometers" });
|
|
77426
77426
|
a < r && (r = a, t = i);
|
|
77427
77427
|
}
|
|
77428
77428
|
});
|
|
77429
77429
|
let p = null, o = null;
|
|
77430
|
-
return
|
|
77431
|
-
const i =
|
|
77430
|
+
return S(y.features[t], function(n) {
|
|
77431
|
+
const i = L(e, n);
|
|
77432
77432
|
p ? i < p && (p = i, o = n) : (p = i, o = n);
|
|
77433
|
-
}),
|
|
77433
|
+
}), f(o);
|
|
77434
77434
|
}
|
|
77435
77435
|
export {
|
|
77436
77436
|
I as default
|