@blogmcp/sdk 0.3.1 → 0.3.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/LICENSE +21 -0
- package/dist/node_modules/maplibre-gl/dist/maplibre-gl.js +1101 -1056
- package/dist/packages/mdx-render-vue/dist/composables/useTripMap.js +21 -25
- package/dist/packages/mdx-render-vue/dist/edit/TripMapEdit.vue.js +1 -0
- package/dist/packages/mdx-render-vue/dist/render/tripmap/TripMapDefault.vue.js +105 -94
- package/dist/packages/mdx-schema/dist/metadata/index.js +9 -0
- package/dist/packages/mdx-schema/dist/styles/index.js +2 -0
- package/dist/packages/mdx-schema/dist/tripmap.js +63 -30
- package/dist/packages/tripmap-core/dist/css.js +93 -16
- package/dist/packages/tripmap-core/dist/detail.js +50 -0
- package/dist/packages/tripmap-core/dist/engine.js +326 -171
- package/dist/packages/tripmap-core/dist/export.js +70 -0
- package/dist/packages/tripmap-core/dist/filmstrip.js +1 -1
- package/dist/packages/tripmap-core/dist/index.js +50 -34
- package/dist/packages/tripmap-core/dist/lightbox.js +94 -0
- package/dist/packages/tripmap-core/dist/markers.js +62 -57
- package/dist/packages/tripmap-core/dist/playback.js +19 -15
- package/dist/packages/tripmap-core/dist/preload.js +44 -0
- package/package.json +2 -2
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
class r {
|
|
2
|
+
constructor(e, a, s) {
|
|
3
|
+
this.callbacks = a, this.labels = s, this.root = e.ownerDocument.createElement("div"), this.root.className = "tripmap-detail", this.root.hidden = !0, e.appendChild(this.root);
|
|
4
|
+
}
|
|
5
|
+
root;
|
|
6
|
+
nodeId = null;
|
|
7
|
+
get element() {
|
|
8
|
+
return this.root;
|
|
9
|
+
}
|
|
10
|
+
get currentId() {
|
|
11
|
+
return this.nodeId;
|
|
12
|
+
}
|
|
13
|
+
show(e) {
|
|
14
|
+
const a = this.root.ownerDocument;
|
|
15
|
+
this.root.textContent = "", this.nodeId = e.id, this.root.dataset.tripmapNode = e.id;
|
|
16
|
+
const s = e.imageUrl || e.thumbnailUrl;
|
|
17
|
+
if (s) {
|
|
18
|
+
const t = this.callbacks.takePreloaded?.(s) ?? a.createElement("img");
|
|
19
|
+
if (t.getAttribute("src") || (t.src = s, t.loading = "eager", t.decoding = "async"), t.alt = e.altText || e.title || "", t.className = "tripmap-detail__img", t.draggable = !1, this.callbacks.onImageClick) {
|
|
20
|
+
const o = a.createElement("button");
|
|
21
|
+
o.type = "button", o.className = "tripmap-detail__zoom", o.setAttribute("aria-label", this.labels.zoomImage), o.appendChild(t), o.addEventListener("click", () => this.callbacks.onImageClick?.(e)), this.root.appendChild(o);
|
|
22
|
+
} else
|
|
23
|
+
this.root.appendChild(t);
|
|
24
|
+
}
|
|
25
|
+
const i = a.createElement("div");
|
|
26
|
+
if (i.className = "tripmap-detail__meta", e.title) {
|
|
27
|
+
const t = a.createElement("strong");
|
|
28
|
+
t.className = "tripmap-detail__title", t.textContent = e.title, i.appendChild(t);
|
|
29
|
+
}
|
|
30
|
+
if (e.capturedAt) {
|
|
31
|
+
const t = a.createElement("span");
|
|
32
|
+
t.className = "tripmap-detail__time", t.textContent = this.callbacks.formatTime(e.capturedAt), i.appendChild(t);
|
|
33
|
+
}
|
|
34
|
+
const l = e.description || e.altText;
|
|
35
|
+
if (l) {
|
|
36
|
+
const t = a.createElement("p");
|
|
37
|
+
t.className = "tripmap-detail__desc", t.textContent = l, i.appendChild(t);
|
|
38
|
+
}
|
|
39
|
+
i.childNodes.length > 0 && this.root.appendChild(i), this.root.hidden = !1;
|
|
40
|
+
}
|
|
41
|
+
clear() {
|
|
42
|
+
this.root.textContent = "", this.root.hidden = !0, this.nodeId = null, delete this.root.dataset.tripmapNode;
|
|
43
|
+
}
|
|
44
|
+
destroy() {
|
|
45
|
+
this.root.remove();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
r as DetailPanel
|
|
50
|
+
};
|
|
@@ -1,255 +1,410 @@
|
|
|
1
|
-
import { Map as
|
|
2
|
-
import { Protocol as
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { Map as ge, AttributionControl as ye, NavigationControl as be, FullscreenControl as we, Popup as ve, setWorkerUrl as Ce, Marker as xe } from "../../../node_modules/maplibre-gl/dist/maplibre-gl.js";
|
|
2
|
+
import { Protocol as Le } from "../../../node_modules/pmtiles/dist/esm/index.js";
|
|
3
|
+
import { ImagePreloader as Ee } from "./preload.js";
|
|
4
|
+
import { mapyRouteUrl as Me, googleMapsRouteUrl as $e, buildGpx as ke, gpxFileName as _e } from "./export.js";
|
|
5
|
+
import { Lightbox as Ne } from "./lightbox.js";
|
|
6
|
+
import { DetailPanel as Ae } from "./detail.js";
|
|
7
|
+
import Se from "./generated/maplibre-worker.bundle.js";
|
|
8
|
+
import { buildAttributions as Te } from "./attribution.js";
|
|
9
|
+
import { injectTripMapCss as Fe } from "./css.js";
|
|
10
|
+
import { Filmstrip as De } from "./filmstrip.js";
|
|
11
|
+
import { computeFramingBounds as Re } from "./framing.js";
|
|
12
|
+
import { buildLineFeature as Ue, LINE_LAYER_PAINT as ze, LINE_LAYER_LAYOUT as Pe } from "./line.js";
|
|
13
|
+
import { createPopupContent as Ie, setMarkerActive as O, MarkerPool as Be, createClusterMarkerEl as He, createNodeMarkerEl as qe } from "./markers.js";
|
|
14
|
+
import { formatTimeHHMM as z, lineNodes as Ze } from "./nodes.js";
|
|
15
|
+
import { startPlayback as Oe } from "./playback.js";
|
|
16
|
+
import { watchSystemTheme as Ve, resolveTheme as V, carryTripMapLayers as je } from "./theme.js";
|
|
17
|
+
import { Mn as Ye } from "../../../node_modules/maplibre-gl/dist/maplibre-gl-shared.js";
|
|
18
|
+
const w = "tripmap-nodes", j = "tripmap-line", Ge = "tripmap-line-layer", We = "tripmap-nodes-anchor", Je = 17;
|
|
19
|
+
let oe = !1;
|
|
20
|
+
function Ke() {
|
|
21
|
+
if (oe) return;
|
|
22
|
+
const l = new Le();
|
|
23
|
+
Ye("pmtiles", l.tile), oe = !0;
|
|
20
24
|
}
|
|
21
|
-
let
|
|
22
|
-
function
|
|
23
|
-
if (!
|
|
24
|
-
|
|
25
|
+
let ae = !1;
|
|
26
|
+
function Qe() {
|
|
27
|
+
if (!ae) {
|
|
28
|
+
ae = !0;
|
|
25
29
|
try {
|
|
26
|
-
const
|
|
27
|
-
|
|
30
|
+
const l = new Blob([Se], { type: "text/javascript" });
|
|
31
|
+
Ce(URL.createObjectURL(l));
|
|
28
32
|
} catch {
|
|
29
33
|
}
|
|
30
34
|
}
|
|
31
35
|
}
|
|
32
|
-
function
|
|
36
|
+
function re(l) {
|
|
33
37
|
return {
|
|
34
38
|
type: "FeatureCollection",
|
|
35
|
-
features:
|
|
39
|
+
features: l.map((n) => ({
|
|
36
40
|
type: "Feature",
|
|
37
|
-
geometry: { type: "Point", coordinates: [
|
|
38
|
-
properties: { id:
|
|
41
|
+
geometry: { type: "Point", coordinates: [n.lng, n.lat] },
|
|
42
|
+
properties: { id: n.id }
|
|
39
43
|
}))
|
|
40
44
|
};
|
|
41
45
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
let
|
|
47
|
-
const
|
|
48
|
-
container:
|
|
49
|
-
style:
|
|
50
|
-
center:
|
|
51
|
-
zoom:
|
|
52
|
-
attributionControl: !1
|
|
46
|
+
function gt(l, n) {
|
|
47
|
+
Qe(), Ke(), Fe(l.ownerDocument), l.classList.add("tripmap");
|
|
48
|
+
const f = l.ownerDocument.createElement("div");
|
|
49
|
+
f.className = "tripmap__map", l.appendChild(f);
|
|
50
|
+
let d = [], _ = /* @__PURE__ */ new Map(), N = null, u = !1, A = !1, Y = !1, C = null, F = null, P = !1;
|
|
51
|
+
const G = (e) => V(e) === "dark" ? n.darkStyleUrl : n.styleUrl, r = new ge({
|
|
52
|
+
container: f,
|
|
53
|
+
style: G(n.theme),
|
|
54
|
+
center: n.initialView?.center ?? [0, 0],
|
|
55
|
+
zoom: n.initialView?.zoom ?? 1,
|
|
56
|
+
attributionControl: !1,
|
|
57
|
+
locale: {
|
|
58
|
+
"FullscreenControl.Enter": n.labels.fullscreen,
|
|
59
|
+
"FullscreenControl.Exit": n.labels.exitFullscreen
|
|
60
|
+
}
|
|
53
61
|
});
|
|
54
|
-
|
|
55
|
-
new
|
|
62
|
+
r.addControl(
|
|
63
|
+
new ye({
|
|
56
64
|
compact: !1,
|
|
57
|
-
customAttribution:
|
|
65
|
+
customAttribution: Te(n.extraAttribution)
|
|
58
66
|
})
|
|
59
|
-
),
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
), r.addControl(new be({ showCompass: !1 }), "top-right"), n.showFullscreen && r.addControl(new we({ container: l }), "top-right");
|
|
68
|
+
const I = l.ownerDocument, W = () => {
|
|
69
|
+
u || (r.resize(), B(), k());
|
|
70
|
+
};
|
|
71
|
+
I.addEventListener("fullscreenchange", W);
|
|
72
|
+
function B() {
|
|
73
|
+
const e = f.clientHeight || 0, a = e > 0 ? Math.max(96, Math.min(180, Math.round(e * 0.4))) : 180;
|
|
74
|
+
l.style.setProperty("--tripmap-popup-img-max", `${a}px`), e > 0 && l.style.setProperty("--tripmap-map-h", `${e}px`);
|
|
75
|
+
}
|
|
76
|
+
B(), r.on("resize", B);
|
|
77
|
+
const S = new Ee(I);
|
|
78
|
+
typeof requestAnimationFrame == "function" && requestAnimationFrame(() => {
|
|
79
|
+
u || r.resize();
|
|
80
|
+
}), r.on("error", (e) => {
|
|
81
|
+
n.events.onError?.(e?.error instanceof Error ? e.error : new Error("tripmap: map error"));
|
|
63
82
|
});
|
|
64
|
-
const
|
|
65
|
-
mount: (e,
|
|
66
|
-
move: (e,
|
|
67
|
-
e.setLngLat(
|
|
83
|
+
const D = new Be({
|
|
84
|
+
mount: (e, a) => new xe({ element: e }).setLngLat(a).addTo(r),
|
|
85
|
+
move: (e, a) => {
|
|
86
|
+
e.setLngLat(a);
|
|
68
87
|
},
|
|
69
88
|
unmount: (e) => e.remove()
|
|
70
89
|
});
|
|
71
|
-
let
|
|
72
|
-
|
|
73
|
-
formatTime:
|
|
90
|
+
let x = null;
|
|
91
|
+
n.showFilmstrip && (x = new De(l, {
|
|
92
|
+
formatTime: z,
|
|
74
93
|
onSelect: (e) => {
|
|
75
|
-
|
|
94
|
+
$(e.id, { fly: !0 }), U(e);
|
|
76
95
|
}
|
|
77
96
|
}));
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
let H = null, R = null;
|
|
98
|
+
const J = new Ne(
|
|
99
|
+
l,
|
|
100
|
+
{ close: n.labels.lightboxClose, prev: n.labels.lightboxPrev, next: n.labels.lightboxNext },
|
|
101
|
+
{
|
|
102
|
+
formatTime: z,
|
|
103
|
+
preload: (e) => {
|
|
104
|
+
S.preload(e);
|
|
105
|
+
},
|
|
106
|
+
onChange: (e) => {
|
|
107
|
+
R = e, e.id !== N && $(e.id, { fly: !1 });
|
|
108
|
+
},
|
|
109
|
+
onClose: () => {
|
|
110
|
+
const e = R;
|
|
111
|
+
R = null, e && e.id !== H && !u && U(e), H = null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
function K(e) {
|
|
116
|
+
H = e.id, R = e, J.open(d, e.id);
|
|
117
|
+
}
|
|
118
|
+
let Q = !1;
|
|
119
|
+
const se = !n.detailHost, L = n.detail === "panel" ? new Ae(
|
|
120
|
+
n.detailHost ?? l,
|
|
121
|
+
{
|
|
122
|
+
formatTime: z,
|
|
123
|
+
onImageClick: K,
|
|
124
|
+
takePreloaded: (e) => S.take(e)
|
|
125
|
+
},
|
|
126
|
+
{ zoomImage: n.labels.zoomImage }
|
|
127
|
+
) : null;
|
|
128
|
+
function U(e) {
|
|
129
|
+
L ? L.show(e) : pe(e);
|
|
130
|
+
}
|
|
131
|
+
function ie() {
|
|
132
|
+
if (!L || !se || Q) return;
|
|
133
|
+
const e = l.getBoundingClientRect().height;
|
|
134
|
+
if (e <= 0) return;
|
|
135
|
+
Q = !0;
|
|
136
|
+
const a = x ? x.element.getBoundingClientRect().height : 0;
|
|
137
|
+
l.classList.add("tripmap--panel"), l.style.height = "auto", f.style.flex = "0 0 auto", f.style.height = `${Math.max(180, Math.round(e - a - (a > 0 ? 8 : 0)))}px`, r.resize();
|
|
138
|
+
}
|
|
139
|
+
const E = l.ownerDocument.createElement("div");
|
|
140
|
+
E.className = "tripmap__controls";
|
|
141
|
+
const g = l.ownerDocument.createElement("button");
|
|
142
|
+
g.type = "button", g.className = "tripmap__ctrl tripmap__play", g.textContent = n.labels.play, g.addEventListener("click", () => {
|
|
143
|
+
C ? C.stop() : ne();
|
|
144
|
+
}), E.appendChild(g);
|
|
145
|
+
const v = l.ownerDocument.createElement("div");
|
|
146
|
+
v.className = "tripmap__export";
|
|
147
|
+
const y = l.ownerDocument.createElement("button");
|
|
148
|
+
y.type = "button", y.className = "tripmap__ctrl tripmap__export-btn", y.textContent = n.labels.export, y.setAttribute("aria-haspopup", "menu"), y.setAttribute("aria-expanded", "false");
|
|
149
|
+
const h = l.ownerDocument.createElement("div");
|
|
150
|
+
h.className = "tripmap__menu", h.setAttribute("role", "menu"), h.hidden = !0, v.appendChild(y), v.appendChild(h), E.appendChild(v);
|
|
151
|
+
const X = (e) => {
|
|
152
|
+
v.contains(e.target) || M();
|
|
153
|
+
}, ee = (e) => {
|
|
154
|
+
e.key === "Escape" && M();
|
|
155
|
+
};
|
|
156
|
+
function M() {
|
|
157
|
+
h.hidden || (h.hidden = !0, y.setAttribute("aria-expanded", "false"), l.ownerDocument.removeEventListener("pointerdown", X, !0), l.ownerDocument.removeEventListener("keydown", ee));
|
|
158
|
+
}
|
|
159
|
+
function le() {
|
|
160
|
+
const e = l.ownerDocument;
|
|
161
|
+
h.textContent = "";
|
|
162
|
+
const a = (s, c, p) => {
|
|
163
|
+
const m = e.createElement(s);
|
|
164
|
+
if (m.className = "tripmap__menu-item", m.setAttribute("role", "menuitem"), m.appendChild(e.createTextNode(c)), p) {
|
|
165
|
+
const b = e.createElement("small");
|
|
166
|
+
b.textContent = p, m.appendChild(b);
|
|
167
|
+
}
|
|
168
|
+
return h.appendChild(m), m;
|
|
169
|
+
}, t = a("button", n.labels.exportGpx, n.labels.exportGpxHint);
|
|
170
|
+
t.type = "button", t.addEventListener("click", () => {
|
|
171
|
+
M(), ce();
|
|
172
|
+
});
|
|
173
|
+
const o = e.defaultView?.matchMedia?.("(pointer: coarse)").matches ?? !1, i = [
|
|
174
|
+
[n.labels.openInMapy, Me(d)],
|
|
175
|
+
[n.labels.openInGoogleMaps, $e(d, { maxWaypoints: o ? 3 : 9 })]
|
|
176
|
+
];
|
|
177
|
+
for (const [s, c] of i) {
|
|
178
|
+
if (!c) continue;
|
|
179
|
+
const p = a("a", s);
|
|
180
|
+
p.href = c, p.target = "_blank", p.rel = "noopener", p.addEventListener("click", () => M());
|
|
181
|
+
}
|
|
182
|
+
h.hidden = !1, y.setAttribute("aria-expanded", "true"), e.addEventListener("pointerdown", X, !0), e.addEventListener("keydown", ee);
|
|
183
|
+
}
|
|
184
|
+
y.addEventListener("click", () => {
|
|
185
|
+
h.hidden ? le() : M();
|
|
186
|
+
});
|
|
187
|
+
async function ce() {
|
|
188
|
+
const e = ke(d, { name: n.title });
|
|
189
|
+
if (!e) return;
|
|
190
|
+
const a = l.ownerDocument, t = a.defaultView, o = _e(n.title), i = "application/gpx+xml";
|
|
191
|
+
if (t && typeof t.File == "function" && t.navigator?.canShare) {
|
|
192
|
+
const m = new t.File([e], o, { type: i });
|
|
193
|
+
if (t.navigator.canShare({ files: [m] }))
|
|
194
|
+
try {
|
|
195
|
+
await t.navigator.share({ files: [m], title: n.title });
|
|
196
|
+
return;
|
|
197
|
+
} catch (b) {
|
|
198
|
+
if (b?.name === "AbortError") return;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const s = new Blob([e], { type: i }), c = URL.createObjectURL(s), p = a.createElement("a");
|
|
202
|
+
p.href = c, p.download = o, p.rel = "noopener", p.style.display = "none", a.body.appendChild(p), p.click(), p.remove(), setTimeout(() => URL.revokeObjectURL(c), 1e4);
|
|
203
|
+
}
|
|
204
|
+
f.appendChild(E), E.style.display = "none";
|
|
205
|
+
function pe(e) {
|
|
206
|
+
F?.remove();
|
|
207
|
+
const a = e.imageUrl || e.thumbnailUrl, t = a ? S.take(a) : null, o = Ie(e, z, {
|
|
208
|
+
image: t ?? void 0,
|
|
209
|
+
onImageClick: K,
|
|
210
|
+
zoomLabel: n.labels.zoomImage
|
|
211
|
+
}), i = new ve({ offset: 26, maxWidth: "280px", className: "tripmap-popup-anchor" }).setLngLat([e.lng, e.lat]).setDOMContent(o).addTo(r);
|
|
212
|
+
F = i;
|
|
213
|
+
const s = () => {
|
|
214
|
+
!u && F === i && me(i);
|
|
215
|
+
};
|
|
216
|
+
requestAnimationFrame(s);
|
|
217
|
+
const c = o.querySelector("img");
|
|
218
|
+
c && !c.complete && c.addEventListener("load", s, { once: !0 });
|
|
219
|
+
}
|
|
220
|
+
function me(e) {
|
|
221
|
+
const a = e.getElement();
|
|
222
|
+
if (!a) return;
|
|
223
|
+
const t = a.getBoundingClientRect(), o = f.getBoundingClientRect();
|
|
224
|
+
if (t.width === 0 || o.width === 0) return;
|
|
225
|
+
const i = 8;
|
|
226
|
+
let s = 0, c = 0;
|
|
227
|
+
t.width > o.width - 2 * i ? s = t.left - (o.left + i) : t.right > o.right - i ? s = t.right - (o.right - i) : t.left < o.left + i && (s = t.left - (o.left + i)), t.height > o.height - 2 * i ? c = t.top - (o.top + i) : t.bottom > o.bottom - i ? c = t.bottom - (o.bottom - i) : t.top < o.top + i && (c = t.top - (o.top + i)), !(Math.abs(s) < 1 && Math.abs(c) < 1) && r.panBy([s, c], { duration: 300, essential: !0 });
|
|
228
|
+
}
|
|
229
|
+
function $(e, a = {}) {
|
|
230
|
+
if (!u) {
|
|
231
|
+
if (N && O(D.get(`n:${N}`), !1), N = e, e && O(D.get(`n:${e}`), !0), x?.setActive(e), e && a.fly) {
|
|
232
|
+
const t = _.get(e);
|
|
233
|
+
t && r.flyTo({
|
|
234
|
+
center: [t.lng, t.lat],
|
|
235
|
+
zoom: Math.max(r.getZoom(), 15),
|
|
94
236
|
essential: !0
|
|
95
237
|
});
|
|
96
238
|
}
|
|
97
|
-
|
|
239
|
+
n.events.onActiveNodeChange?.(e);
|
|
98
240
|
}
|
|
99
241
|
}
|
|
100
|
-
function
|
|
101
|
-
|
|
102
|
-
|
|
242
|
+
function k() {
|
|
243
|
+
P || u || (P = !0, requestAnimationFrame(() => {
|
|
244
|
+
P = !1, de();
|
|
103
245
|
}));
|
|
104
246
|
}
|
|
105
|
-
function
|
|
106
|
-
if (
|
|
107
|
-
const e =
|
|
108
|
-
for (const
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
111
|
-
const s =
|
|
112
|
-
if (
|
|
113
|
-
const
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
key:
|
|
247
|
+
function de() {
|
|
248
|
+
if (u || !A || !r.getSource(w)) return;
|
|
249
|
+
const e = r.querySourceFeatures(w), a = [], t = /* @__PURE__ */ new Set();
|
|
250
|
+
for (const o of e) {
|
|
251
|
+
const i = o.geometry;
|
|
252
|
+
if (i.type !== "Point") continue;
|
|
253
|
+
const s = i.coordinates, c = o.properties;
|
|
254
|
+
if (c.cluster) {
|
|
255
|
+
const p = c.cluster_id, m = `c:${p}`;
|
|
256
|
+
if (t.has(m)) continue;
|
|
257
|
+
t.add(m);
|
|
258
|
+
const b = c.point_count ?? 0;
|
|
259
|
+
a.push({
|
|
260
|
+
key: m,
|
|
119
261
|
lngLat: s,
|
|
120
262
|
createEl: () => {
|
|
121
|
-
const
|
|
122
|
-
return
|
|
263
|
+
const T = He(b, void 0, () => fe(p, s));
|
|
264
|
+
return ue(T, p), T;
|
|
123
265
|
}
|
|
124
266
|
});
|
|
125
267
|
} else {
|
|
126
|
-
const
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
const
|
|
130
|
-
if (!
|
|
131
|
-
|
|
132
|
-
key:
|
|
268
|
+
const p = c.id, m = `n:${p}`;
|
|
269
|
+
if (t.has(m)) continue;
|
|
270
|
+
t.add(m);
|
|
271
|
+
const b = _.get(p);
|
|
272
|
+
if (!b) continue;
|
|
273
|
+
a.push({
|
|
274
|
+
key: m,
|
|
133
275
|
lngLat: s,
|
|
134
276
|
createEl: () => {
|
|
135
|
-
const
|
|
136
|
-
|
|
277
|
+
const T = qe(b, (Z) => {
|
|
278
|
+
$(Z.id, { fly: !1 }), U(Z), n.events.onNodeClick?.(Z);
|
|
137
279
|
});
|
|
138
|
-
return
|
|
280
|
+
return p === N && O(T, !0), T;
|
|
139
281
|
}
|
|
140
282
|
});
|
|
141
283
|
}
|
|
142
284
|
}
|
|
143
|
-
|
|
285
|
+
D.sync(a);
|
|
144
286
|
}
|
|
145
|
-
async function
|
|
287
|
+
async function ue(e, a) {
|
|
146
288
|
try {
|
|
147
|
-
const
|
|
148
|
-
if (!
|
|
149
|
-
const
|
|
150
|
-
if (!
|
|
289
|
+
const t = r.getSource(w);
|
|
290
|
+
if (!t) return;
|
|
291
|
+
const o = (await t.getClusterLeaves(a, 1, 0))?.[0]?.properties?.id, i = o ? _.get(o)?.thumbnailUrl : void 0;
|
|
292
|
+
if (!i || !e.isConnected) return;
|
|
151
293
|
const s = e.ownerDocument.createElement("img");
|
|
152
|
-
s.src =
|
|
294
|
+
s.src = i, s.alt = "", s.loading = "lazy", s.decoding = "async", s.draggable = !1, s.className = "tripmap-marker__img", e.prepend(s);
|
|
153
295
|
} catch {
|
|
154
296
|
}
|
|
155
297
|
}
|
|
156
|
-
function
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
298
|
+
function fe(e, a) {
|
|
299
|
+
const t = r.getSource(w);
|
|
300
|
+
t && (t.getClusterExpansionZoom(e).then((o) => {
|
|
301
|
+
u || r.easeTo({ center: a, zoom: Math.min(o + 0.5, 19) });
|
|
160
302
|
}).catch(() => {
|
|
161
|
-
})
|
|
303
|
+
}), t.getClusterLeaves(e, 1, 0).then((o) => {
|
|
304
|
+
const i = o?.[0]?.properties?.id, s = i ? _.get(i) : void 0;
|
|
305
|
+
u || !s || ($(s.id, { fly: !1 }), L && L.show(s));
|
|
306
|
+
}).catch(() => {
|
|
307
|
+
}));
|
|
162
308
|
}
|
|
163
|
-
function
|
|
164
|
-
if (
|
|
165
|
-
const e =
|
|
166
|
-
e ? e.setData(
|
|
309
|
+
function q() {
|
|
310
|
+
if (u || !A) return;
|
|
311
|
+
const e = r.getSource(w);
|
|
312
|
+
e ? e.setData(re(d)) : (r.addSource(w, {
|
|
167
313
|
type: "geojson",
|
|
168
|
-
data:
|
|
169
|
-
cluster:
|
|
170
|
-
clusterRadius:
|
|
171
|
-
clusterMaxZoom:
|
|
172
|
-
}),
|
|
173
|
-
id:
|
|
314
|
+
data: re(d),
|
|
315
|
+
cluster: n.cluster,
|
|
316
|
+
clusterRadius: n.clusterRadius,
|
|
317
|
+
clusterMaxZoom: Je
|
|
318
|
+
}), r.addLayer({
|
|
319
|
+
id: We,
|
|
174
320
|
type: "circle",
|
|
175
|
-
source:
|
|
321
|
+
source: w,
|
|
176
322
|
paint: { "circle-radius": 0, "circle-opacity": 0 }
|
|
177
323
|
}));
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
id:
|
|
324
|
+
const a = n.showLine ? Ue(d) : null, t = r.getSource(j), o = a ?? { type: "FeatureCollection", features: [] };
|
|
325
|
+
t ? t.setData(o) : a && (r.addSource(j, { type: "geojson", data: o, lineMetrics: !0 }), r.addLayer({
|
|
326
|
+
id: Ge,
|
|
181
327
|
type: "line",
|
|
182
|
-
source:
|
|
183
|
-
layout:
|
|
184
|
-
paint:
|
|
185
|
-
}))
|
|
186
|
-
|
|
187
|
-
|
|
328
|
+
source: j,
|
|
329
|
+
layout: Pe,
|
|
330
|
+
paint: ze
|
|
331
|
+
}));
|
|
332
|
+
const i = Ze(d).length, s = i >= 2;
|
|
333
|
+
if (g.hidden = !(n.showPlayback && s), v.hidden = !(n.showExport && s), E.style.display = g.hidden && v.hidden ? "none" : "", l.dataset.tripmapNodes = String(d.length), l.dataset.tripmapRoute = String(i), l.dataset.tripmapLine = String(!!a), l.dataset.tripmapTheme = V(n.theme), x?.setNodes(d), d.length > 0 && ie(), !Y && d.length > 0 && !n.initialView?.center) {
|
|
334
|
+
const c = Re(d);
|
|
335
|
+
c && (r.fitBounds(c, { padding: 56, maxZoom: 15, duration: 0 }), Y = !0);
|
|
188
336
|
}
|
|
189
|
-
|
|
337
|
+
k();
|
|
190
338
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}),
|
|
194
|
-
e.sourceId ===
|
|
339
|
+
r.on("load", () => {
|
|
340
|
+
A = !0, q(), n.events.onReady?.();
|
|
341
|
+
}), r.on("moveend", k), r.on("zoomend", k), r.on("idle", k), r.on("sourcedata", (e) => {
|
|
342
|
+
e.sourceId === w && e.isSourceLoaded && k();
|
|
195
343
|
});
|
|
196
|
-
const
|
|
197
|
-
|
|
344
|
+
const he = n.theme === "auto" ? Ve(() => {
|
|
345
|
+
u || te("auto");
|
|
198
346
|
}) : () => {
|
|
199
347
|
};
|
|
200
|
-
function
|
|
201
|
-
if (
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
transformStyle: (
|
|
205
|
-
}),
|
|
206
|
-
|
|
348
|
+
function te(e) {
|
|
349
|
+
if (u) return;
|
|
350
|
+
const a = G(e);
|
|
351
|
+
l.dataset.tripmapTheme = V(e), A = !1, r.setStyle(a, {
|
|
352
|
+
transformStyle: (t, o) => je(t, o)
|
|
353
|
+
}), r.once("styledata", () => {
|
|
354
|
+
A = !0, q();
|
|
207
355
|
});
|
|
208
356
|
}
|
|
209
|
-
function
|
|
210
|
-
|
|
211
|
-
const
|
|
212
|
-
|
|
357
|
+
function ne(e = {}) {
|
|
358
|
+
C?.stop(), g.textContent = n.labels.stop;
|
|
359
|
+
const a = Oe(
|
|
360
|
+
d,
|
|
213
361
|
{
|
|
214
|
-
flyTo: (
|
|
215
|
-
|
|
216
|
-
center: [
|
|
217
|
-
zoom: Math.max(
|
|
362
|
+
flyTo: (t) => new Promise((o) => {
|
|
363
|
+
r.once("moveend", () => o()), r.flyTo({
|
|
364
|
+
center: [t.lng, t.lat],
|
|
365
|
+
zoom: Math.max(r.getZoom(), 14),
|
|
218
366
|
speed: 0.9,
|
|
219
|
-
essential: !0
|
|
367
|
+
essential: !0,
|
|
368
|
+
// Land the node in the upper third so its popup (which opens
|
|
369
|
+
// below it) has two thirds of the viewport instead of one half.
|
|
370
|
+
offset: [0, -Math.round((f.clientHeight || 0) * 0.18)]
|
|
220
371
|
});
|
|
221
372
|
}),
|
|
222
|
-
showNode: (
|
|
223
|
-
|
|
373
|
+
showNode: (t) => {
|
|
374
|
+
$(t.id, { fly: !1 }), U(t);
|
|
375
|
+
},
|
|
376
|
+
preload: (t) => {
|
|
377
|
+
const o = t.imageUrl || t.thumbnailUrl;
|
|
378
|
+
return o ? S.preload(o) : void 0;
|
|
224
379
|
},
|
|
225
380
|
onDone: () => {
|
|
226
|
-
|
|
381
|
+
C = null, g.textContent = n.labels.play;
|
|
227
382
|
},
|
|
228
|
-
onUserInterrupt: (
|
|
229
|
-
const
|
|
230
|
-
return
|
|
383
|
+
onUserInterrupt: (t) => {
|
|
384
|
+
const o = r.getCanvasContainer(), i = ["pointerdown", "wheel"];
|
|
385
|
+
return i.forEach((s) => o.addEventListener(s, t, { passive: !0 })), () => i.forEach((s) => o.removeEventListener(s, t));
|
|
231
386
|
}
|
|
232
387
|
},
|
|
233
388
|
e
|
|
234
389
|
);
|
|
235
|
-
return
|
|
390
|
+
return C = a, a;
|
|
236
391
|
}
|
|
237
392
|
return {
|
|
238
|
-
_map:
|
|
393
|
+
_map: r,
|
|
239
394
|
setNodes(e) {
|
|
240
|
-
|
|
395
|
+
d = e, _ = new Map(e.map((a) => [a.id, a])), q();
|
|
241
396
|
},
|
|
242
|
-
setActiveNode:
|
|
243
|
-
playSequence:
|
|
244
|
-
setTheme:
|
|
397
|
+
setActiveNode: $,
|
|
398
|
+
playSequence: ne,
|
|
399
|
+
setTheme: te,
|
|
245
400
|
resize() {
|
|
246
|
-
|
|
401
|
+
u || r.resize();
|
|
247
402
|
},
|
|
248
403
|
destroy() {
|
|
249
|
-
|
|
404
|
+
u || (u = !0, C?.stop(), he(), I.removeEventListener("fullscreenchange", W), M(), J.destroy(), L?.destroy(), S.clear(), F?.remove(), D.clear(), x?.destroy(), r.remove(), f.remove(), l.classList.remove("tripmap"));
|
|
250
405
|
}
|
|
251
406
|
};
|
|
252
407
|
}
|
|
253
408
|
export {
|
|
254
|
-
|
|
409
|
+
gt as createEngine
|
|
255
410
|
};
|