@remotion/maptiler 4.0.514

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,7 @@
1
+ # @remotion/maptiler
2
+
3
+ MapTiler components for Remotion
4
+
5
+ ## Usage
6
+
7
+ This is an internal package and has no documentation.
@@ -0,0 +1,8 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type InteractiveBaseProps, type InteractiveTransformProps, type SequenceControls } from 'remotion';
3
+ export declare const MapOverlay: import("react").ComponentType<InteractiveBaseProps & InteractiveTransformProps & {
4
+ readonly children?: ReactNode;
5
+ readonly controls?: SequenceControls | undefined;
6
+ readonly latitude: number;
7
+ readonly longitude: number;
8
+ } & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,23 @@
1
+ import { type InteractiveBaseProps, type SequenceControls } from 'remotion';
2
+ export type MapRegionFeature = {
3
+ type: 'Feature';
4
+ properties: {
5
+ name: string;
6
+ source: string;
7
+ };
8
+ geometry: {
9
+ type: 'Polygon';
10
+ coordinates: number[][][];
11
+ };
12
+ };
13
+ export declare const MapRegion: import("react").ComponentType<InteractiveBaseProps & {
14
+ readonly controls?: SequenceControls | undefined;
15
+ readonly feature: MapRegionFeature;
16
+ readonly fill?: number | undefined;
17
+ readonly fillColor: string;
18
+ readonly glow?: number | undefined;
19
+ readonly id: string;
20
+ readonly progress?: number | undefined;
21
+ readonly strokeColor?: string | undefined;
22
+ readonly strokeWidth?: number | undefined;
23
+ } & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,21 @@
1
+ import { type InteractiveBaseProps, type SequenceControls } from 'remotion';
2
+ export type MapRouteFeature = {
3
+ type: 'Feature';
4
+ properties: {
5
+ name: string;
6
+ source: string;
7
+ };
8
+ geometry: {
9
+ type: 'LineString';
10
+ coordinates: number[][];
11
+ };
12
+ };
13
+ export declare const MapRoute: import("react").ComponentType<InteractiveBaseProps & {
14
+ readonly controls?: SequenceControls | undefined;
15
+ readonly feature: MapRouteFeature;
16
+ readonly glow?: number | undefined;
17
+ readonly id: string;
18
+ readonly progress?: number | undefined;
19
+ readonly strokeColor?: string | undefined;
20
+ readonly strokeWidth?: number | undefined;
21
+ } & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,6 @@
1
+ import type { Map as MapTilerMap } from '@maptiler/sdk';
2
+ export type MapTilerContextValue = {
3
+ readonly cameraRevision: number;
4
+ readonly map: MapTilerMap | null;
5
+ };
6
+ export declare const MapTilerContext: import("react").Context<MapTilerContextValue>;
@@ -0,0 +1,13 @@
1
+ import '@maptiler/sdk/style.css';
2
+ import type { ReactNode } from 'react';
3
+ import { type InteractiveBaseProps, type SequenceControls } from 'remotion';
4
+ export declare const MapViewport: import("react").ComponentType<InteractiveBaseProps & {
5
+ readonly apiKey: string | null;
6
+ readonly backgroundColor?: string | undefined;
7
+ readonly bearing?: number | undefined;
8
+ readonly centerLatitude?: number | undefined;
9
+ readonly centerLongitude?: number | undefined;
10
+ readonly children?: ReactNode;
11
+ readonly controls?: SequenceControls | undefined;
12
+ readonly zoom?: number | undefined;
13
+ } & import("react").RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,900 @@
1
+ // src/MapOverlay.tsx
2
+ import {
3
+ forwardRef,
4
+ useContext,
5
+ useImperativeHandle,
6
+ useRef
7
+ } from "react";
8
+ import {
9
+ Interactive,
10
+ Sequence
11
+ } from "remotion";
12
+
13
+ // src/MapTilerContext.ts
14
+ import { createContext } from "react";
15
+ var MapTilerContext = createContext({
16
+ cameraRevision: 0,
17
+ map: null
18
+ });
19
+
20
+ // src/MapOverlay.tsx
21
+ import { jsx } from "react/jsx-runtime";
22
+ var mapOverlaySchema = {
23
+ ...Interactive.baseSchema,
24
+ longitude: {
25
+ type: "number",
26
+ min: -180,
27
+ max: 180,
28
+ step: 0.0001,
29
+ default: 0,
30
+ description: "Longitude",
31
+ hiddenFromList: false
32
+ },
33
+ latitude: {
34
+ type: "number",
35
+ min: -90,
36
+ max: 90,
37
+ step: 0.0001,
38
+ default: 0,
39
+ description: "Latitude",
40
+ hiddenFromList: false
41
+ },
42
+ ...Interactive.transformSchema
43
+ };
44
+ var MapOverlayRefForwardingFunction = ({
45
+ children,
46
+ latitude,
47
+ longitude,
48
+ style,
49
+ durationInFrames,
50
+ from,
51
+ trimBefore,
52
+ freeze,
53
+ hidden,
54
+ name,
55
+ showInTimeline,
56
+ controls
57
+ }, ref) => {
58
+ const { map } = useContext(MapTilerContext);
59
+ const refForOutline = useRef(null);
60
+ const point = map?.project([longitude, latitude]);
61
+ useImperativeHandle(ref, () => refForOutline.current, []);
62
+ return /* @__PURE__ */ jsx(Sequence, {
63
+ layout: "none",
64
+ from: from ?? 0,
65
+ trimBefore,
66
+ durationInFrames: durationInFrames ?? Infinity,
67
+ freeze,
68
+ hidden,
69
+ name: name ?? "<MapOverlay>",
70
+ showInTimeline: showInTimeline ?? true,
71
+ controls,
72
+ outlineRef: refForOutline,
73
+ children: /* @__PURE__ */ jsx("div", {
74
+ ref: refForOutline,
75
+ style: {
76
+ left: point?.x ?? 0,
77
+ pointerEvents: "none",
78
+ position: "absolute",
79
+ top: point?.y ?? 0,
80
+ zIndex: 1,
81
+ ...style
82
+ },
83
+ children
84
+ })
85
+ });
86
+ };
87
+ var MapOverlayInner = forwardRef(MapOverlayRefForwardingFunction);
88
+ var MapOverlay = Interactive.withSchema({
89
+ Component: MapOverlayInner,
90
+ componentName: "<MapOverlay>",
91
+ componentIdentity: null,
92
+ schema: mapOverlaySchema,
93
+ supportsEffects: false
94
+ });
95
+ // src/MapRegion.tsx
96
+ import { length as getLineLength, lineSliceAlong, lineString } from "@turf/turf";
97
+ import {
98
+ forwardRef as forwardRef2,
99
+ useContext as useContext2,
100
+ useEffect,
101
+ useImperativeHandle as useImperativeHandle2,
102
+ useMemo,
103
+ useRef as useRef2,
104
+ useState
105
+ } from "react";
106
+ import {
107
+ Interactive as Interactive2,
108
+ Sequence as Sequence2,
109
+ useDelayRender
110
+ } from "remotion";
111
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
112
+ var mapRegionSchema = {
113
+ ...Interactive2.baseSchema,
114
+ fill: {
115
+ type: "number",
116
+ min: 0,
117
+ max: 1,
118
+ step: 0.01,
119
+ default: 0,
120
+ description: "Fill opacity",
121
+ hiddenFromList: false
122
+ },
123
+ fillColor: {
124
+ type: "color",
125
+ default: "#d52b1e",
126
+ description: "Fill color",
127
+ keyframable: true
128
+ },
129
+ glow: {
130
+ type: "number",
131
+ min: 0,
132
+ max: 1,
133
+ step: 0.01,
134
+ default: 0.72,
135
+ description: "Glow intensity",
136
+ hiddenFromList: false,
137
+ keyframable: true
138
+ },
139
+ progress: {
140
+ type: "number",
141
+ min: 0,
142
+ max: 1,
143
+ step: 0.01,
144
+ default: 1,
145
+ description: "Outline drawing progress",
146
+ hiddenFromList: false
147
+ },
148
+ strokeColor: {
149
+ type: "color",
150
+ default: "#8f1712",
151
+ description: "Stroke color"
152
+ },
153
+ strokeWidth: {
154
+ type: "number",
155
+ min: 0,
156
+ max: 50,
157
+ step: 1,
158
+ default: 9,
159
+ description: "Stroke width",
160
+ hiddenFromList: false
161
+ }
162
+ };
163
+ var MapRegionDrawing = ({
164
+ feature,
165
+ fill = 0,
166
+ fillColor,
167
+ glow = 0.72,
168
+ id,
169
+ progress = 1,
170
+ strokeColor = "#8f1712",
171
+ strokeWidth = 9
172
+ }) => {
173
+ const { map } = useContext2(MapTilerContext);
174
+ const { continueRender, delayRender } = useDelayRender();
175
+ const [isReady, setIsReady] = useState(false);
176
+ const [loadingHandle] = useState(() => delayRender(`Loading ${feature.properties.name} geometry`));
177
+ const outline = useMemo(() => lineString(feature.geometry.coordinates[0]), [feature]);
178
+ const outlineLength = useMemo(() => getLineLength(outline), [outline]);
179
+ const fillSourceId = `${id}-fill`;
180
+ const outlineSourceId = `${id}-outline`;
181
+ const outlineGlowLayerId = `${id}-outline-glow`;
182
+ useEffect(() => {
183
+ if (!map) {
184
+ return;
185
+ }
186
+ if (!map.getSource(fillSourceId)) {
187
+ map.addSource(fillSourceId, {
188
+ data: feature,
189
+ type: "geojson"
190
+ });
191
+ }
192
+ if (!map.getLayer(fillSourceId)) {
193
+ map.addLayer({
194
+ id: fillSourceId,
195
+ paint: {
196
+ "fill-color": fillColor,
197
+ "fill-color-transition": { delay: 0, duration: 0 },
198
+ "fill-opacity": 0,
199
+ "fill-opacity-transition": { delay: 0, duration: 0 }
200
+ },
201
+ source: fillSourceId,
202
+ type: "fill"
203
+ });
204
+ }
205
+ map.setPaintProperty(fillSourceId, "fill-color", fillColor);
206
+ if (!map.getSource(outlineSourceId)) {
207
+ map.addSource(outlineSourceId, {
208
+ data: lineSliceAlong(outline, 0, 0.001),
209
+ type: "geojson"
210
+ });
211
+ }
212
+ if (!map.getLayer(outlineGlowLayerId)) {
213
+ map.addLayer({
214
+ id: outlineGlowLayerId,
215
+ layout: { "line-cap": "round", "line-join": "round" },
216
+ paint: {
217
+ "line-blur": 8,
218
+ "line-color": "#ffffff",
219
+ "line-opacity": glow,
220
+ "line-opacity-transition": { delay: 0, duration: 0 },
221
+ "line-width": 22
222
+ },
223
+ source: outlineSourceId,
224
+ type: "line"
225
+ });
226
+ }
227
+ map.setPaintProperty(outlineGlowLayerId, "line-opacity", Math.min(1, Math.max(0, glow)));
228
+ if (!map.getLayer(outlineSourceId)) {
229
+ map.addLayer({
230
+ id: outlineSourceId,
231
+ layout: { "line-cap": "round", "line-join": "round" },
232
+ paint: {
233
+ "line-color": strokeColor,
234
+ "line-color-transition": { delay: 0, duration: 0 },
235
+ "line-opacity": 1,
236
+ "line-width": strokeWidth,
237
+ "line-width-transition": { delay: 0, duration: 0 }
238
+ },
239
+ source: outlineSourceId,
240
+ type: "line"
241
+ });
242
+ }
243
+ map.setPaintProperty(outlineSourceId, "line-color", strokeColor);
244
+ map.setPaintProperty(outlineSourceId, "line-width", strokeWidth);
245
+ map.once("idle", () => {
246
+ setIsReady(true);
247
+ continueRender(loadingHandle);
248
+ });
249
+ map.triggerRepaint();
250
+ }, [
251
+ continueRender,
252
+ feature,
253
+ fillColor,
254
+ fillSourceId,
255
+ glow,
256
+ loadingHandle,
257
+ map,
258
+ outline,
259
+ outlineGlowLayerId,
260
+ outlineSourceId,
261
+ strokeColor,
262
+ strokeWidth
263
+ ]);
264
+ useEffect(() => {
265
+ if (!isReady || !map) {
266
+ return;
267
+ }
268
+ const frameHandle = delayRender(`Drawing ${feature.properties.name}`);
269
+ map.getSource(outlineSourceId).setData(lineSliceAlong(outline, 0, Math.max(0.001, outlineLength * Math.min(1, Math.max(0, progress)))));
270
+ map.setPaintProperty(fillSourceId, "fill-opacity", Math.min(1, Math.max(0, fill)));
271
+ map.once("idle", () => continueRender(frameHandle));
272
+ map.triggerRepaint();
273
+ }, [
274
+ continueRender,
275
+ delayRender,
276
+ feature.properties.name,
277
+ fill,
278
+ fillSourceId,
279
+ isReady,
280
+ map,
281
+ outline,
282
+ outlineLength,
283
+ outlineSourceId,
284
+ progress
285
+ ]);
286
+ useEffect(() => {
287
+ if (!map) {
288
+ return;
289
+ }
290
+ return () => {
291
+ if (map.getLayer(outlineSourceId)) {
292
+ map.removeLayer(outlineSourceId);
293
+ }
294
+ if (map.getLayer(outlineGlowLayerId)) {
295
+ map.removeLayer(outlineGlowLayerId);
296
+ }
297
+ if (map.getLayer(fillSourceId)) {
298
+ map.removeLayer(fillSourceId);
299
+ }
300
+ if (map.getSource(outlineSourceId)) {
301
+ map.removeSource(outlineSourceId);
302
+ }
303
+ if (map.getSource(fillSourceId)) {
304
+ map.removeSource(fillSourceId);
305
+ }
306
+ map.triggerRepaint();
307
+ };
308
+ }, [fillSourceId, map, outlineGlowLayerId, outlineSourceId]);
309
+ return null;
310
+ };
311
+ var MapRegionBounds = ({
312
+ feature,
313
+ refForOutline
314
+ }) => {
315
+ const { map } = useContext2(MapTilerContext);
316
+ if (!map) {
317
+ return /* @__PURE__ */ jsx2("div", {
318
+ ref: refForOutline
319
+ });
320
+ }
321
+ const points = feature.geometry.coordinates.flat().map(([longitude, latitude]) => map.project([longitude, latitude]));
322
+ const left = Math.min(...points.map((point) => point.x));
323
+ const right = Math.max(...points.map((point) => point.x));
324
+ const top = Math.min(...points.map((point) => point.y));
325
+ const bottom = Math.max(...points.map((point) => point.y));
326
+ return /* @__PURE__ */ jsx2("div", {
327
+ ref: refForOutline,
328
+ style: {
329
+ height: bottom - top,
330
+ left,
331
+ opacity: 0,
332
+ pointerEvents: "none",
333
+ position: "absolute",
334
+ top,
335
+ width: right - left,
336
+ zIndex: 1
337
+ }
338
+ });
339
+ };
340
+ var MapRegionRefForwardingFunction = ({
341
+ feature,
342
+ fill = 0,
343
+ fillColor,
344
+ glow = 0.72,
345
+ id,
346
+ progress = 1,
347
+ strokeColor = "#8f1712",
348
+ strokeWidth = 9,
349
+ durationInFrames,
350
+ from,
351
+ trimBefore,
352
+ freeze,
353
+ hidden,
354
+ name,
355
+ showInTimeline,
356
+ controls
357
+ }, ref) => {
358
+ const refForOutline = useRef2(null);
359
+ useImperativeHandle2(ref, () => refForOutline.current, []);
360
+ return /* @__PURE__ */ jsxs(Sequence2, {
361
+ layout: "none",
362
+ from: from ?? 0,
363
+ trimBefore,
364
+ durationInFrames: durationInFrames ?? Infinity,
365
+ freeze,
366
+ hidden,
367
+ name: name ?? `<${feature.properties.name}>`,
368
+ showInTimeline: showInTimeline ?? true,
369
+ controls,
370
+ outlineRef: refForOutline,
371
+ children: [
372
+ /* @__PURE__ */ jsx2(MapRegionDrawing, {
373
+ feature,
374
+ fill,
375
+ fillColor,
376
+ glow,
377
+ id,
378
+ progress,
379
+ strokeColor,
380
+ strokeWidth
381
+ }),
382
+ /* @__PURE__ */ jsx2(MapRegionBounds, {
383
+ feature,
384
+ refForOutline
385
+ })
386
+ ]
387
+ });
388
+ };
389
+ var MapRegionInner = forwardRef2(MapRegionRefForwardingFunction);
390
+ var MapRegion = Interactive2.withSchema({
391
+ Component: MapRegionInner,
392
+ componentName: "<MapRegion>",
393
+ componentIdentity: null,
394
+ schema: mapRegionSchema,
395
+ supportsEffects: false
396
+ });
397
+ // src/MapRoute.tsx
398
+ import { length as getLineLength2, lineSliceAlong as lineSliceAlong2, lineString as lineString2 } from "@turf/turf";
399
+ import {
400
+ forwardRef as forwardRef3,
401
+ useContext as useContext3,
402
+ useEffect as useEffect2,
403
+ useImperativeHandle as useImperativeHandle3,
404
+ useMemo as useMemo2,
405
+ useRef as useRef3,
406
+ useState as useState2
407
+ } from "react";
408
+ import {
409
+ Interactive as Interactive3,
410
+ Sequence as Sequence3,
411
+ useDelayRender as useDelayRender2
412
+ } from "remotion";
413
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
414
+ var mapRouteSchema = {
415
+ ...Interactive3.baseSchema,
416
+ glow: {
417
+ type: "number",
418
+ min: 0,
419
+ max: 1,
420
+ step: 0.01,
421
+ default: 0.72,
422
+ description: "Glow intensity",
423
+ hiddenFromList: false,
424
+ keyframable: true
425
+ },
426
+ progress: {
427
+ type: "number",
428
+ min: 0,
429
+ max: 1,
430
+ step: 0.01,
431
+ default: 1,
432
+ description: "Route drawing progress",
433
+ hiddenFromList: false
434
+ },
435
+ strokeColor: {
436
+ type: "color",
437
+ default: "#006cff",
438
+ description: "Stroke color"
439
+ },
440
+ strokeWidth: {
441
+ type: "number",
442
+ min: 0,
443
+ max: 50,
444
+ step: 1,
445
+ default: 9,
446
+ description: "Stroke width",
447
+ hiddenFromList: false
448
+ }
449
+ };
450
+ var MapRouteDrawing = ({
451
+ feature,
452
+ glow = 0.72,
453
+ id,
454
+ progress = 1,
455
+ strokeColor = "#006cff",
456
+ strokeWidth = 9
457
+ }) => {
458
+ const { map } = useContext3(MapTilerContext);
459
+ const { continueRender, delayRender } = useDelayRender2();
460
+ const [isReady, setIsReady] = useState2(false);
461
+ const [loadingHandle] = useState2(() => delayRender(`Loading ${feature.properties.name} route`));
462
+ const route = useMemo2(() => lineString2(feature.geometry.coordinates), [feature]);
463
+ const routeLength = useMemo2(() => getLineLength2(route), [route]);
464
+ const sourceId = `${id}-route`;
465
+ const glowLayerId = `${id}-route-glow`;
466
+ useEffect2(() => {
467
+ if (!map) {
468
+ return;
469
+ }
470
+ if (!map.getSource(sourceId)) {
471
+ map.addSource(sourceId, {
472
+ data: lineSliceAlong2(route, 0, 0.001),
473
+ type: "geojson"
474
+ });
475
+ }
476
+ if (!map.getLayer(glowLayerId)) {
477
+ map.addLayer({
478
+ id: glowLayerId,
479
+ layout: { "line-cap": "round", "line-join": "round" },
480
+ paint: {
481
+ "line-blur": 8,
482
+ "line-color": "#ffffff",
483
+ "line-opacity": glow,
484
+ "line-opacity-transition": { delay: 0, duration: 0 },
485
+ "line-width": 22
486
+ },
487
+ source: sourceId,
488
+ type: "line"
489
+ });
490
+ }
491
+ map.setPaintProperty(glowLayerId, "line-opacity", Math.min(1, Math.max(0, glow)));
492
+ if (!map.getLayer(sourceId)) {
493
+ map.addLayer({
494
+ id: sourceId,
495
+ layout: { "line-cap": "round", "line-join": "round" },
496
+ paint: {
497
+ "line-color": strokeColor,
498
+ "line-color-transition": { delay: 0, duration: 0 },
499
+ "line-opacity": 1,
500
+ "line-width": strokeWidth,
501
+ "line-width-transition": { delay: 0, duration: 0 }
502
+ },
503
+ source: sourceId,
504
+ type: "line"
505
+ });
506
+ }
507
+ map.setPaintProperty(sourceId, "line-color", strokeColor);
508
+ map.setPaintProperty(sourceId, "line-width", strokeWidth);
509
+ map.once("idle", () => {
510
+ setIsReady(true);
511
+ continueRender(loadingHandle);
512
+ });
513
+ map.triggerRepaint();
514
+ }, [
515
+ continueRender,
516
+ glow,
517
+ glowLayerId,
518
+ loadingHandle,
519
+ map,
520
+ route,
521
+ sourceId,
522
+ strokeColor,
523
+ strokeWidth
524
+ ]);
525
+ useEffect2(() => {
526
+ if (!isReady || !map) {
527
+ return;
528
+ }
529
+ const frameHandle = delayRender(`Drawing ${feature.properties.name} route`);
530
+ map.getSource(sourceId).setData(lineSliceAlong2(route, 0, Math.max(0.001, routeLength * Math.min(1, Math.max(0, progress)))));
531
+ map.once("idle", () => continueRender(frameHandle));
532
+ map.triggerRepaint();
533
+ }, [
534
+ continueRender,
535
+ delayRender,
536
+ feature.properties.name,
537
+ isReady,
538
+ map,
539
+ progress,
540
+ route,
541
+ routeLength,
542
+ sourceId
543
+ ]);
544
+ useEffect2(() => {
545
+ if (!map) {
546
+ return;
547
+ }
548
+ return () => {
549
+ if (map.getLayer(sourceId)) {
550
+ map.removeLayer(sourceId);
551
+ }
552
+ if (map.getLayer(glowLayerId)) {
553
+ map.removeLayer(glowLayerId);
554
+ }
555
+ if (map.getSource(sourceId)) {
556
+ map.removeSource(sourceId);
557
+ }
558
+ map.triggerRepaint();
559
+ };
560
+ }, [glowLayerId, map, sourceId]);
561
+ return null;
562
+ };
563
+ var MapRouteBounds = ({
564
+ feature,
565
+ refForOutline
566
+ }) => {
567
+ const { map } = useContext3(MapTilerContext);
568
+ if (!map) {
569
+ return /* @__PURE__ */ jsx3("div", {
570
+ ref: refForOutline
571
+ });
572
+ }
573
+ const points = feature.geometry.coordinates.map(([longitude, latitude]) => map.project([longitude, latitude]));
574
+ const left = Math.min(...points.map((point) => point.x));
575
+ const right = Math.max(...points.map((point) => point.x));
576
+ const top = Math.min(...points.map((point) => point.y));
577
+ const bottom = Math.max(...points.map((point) => point.y));
578
+ return /* @__PURE__ */ jsx3("div", {
579
+ ref: refForOutline,
580
+ style: {
581
+ height: bottom - top,
582
+ left,
583
+ opacity: 0,
584
+ pointerEvents: "none",
585
+ position: "absolute",
586
+ top,
587
+ width: right - left,
588
+ zIndex: 1
589
+ }
590
+ });
591
+ };
592
+ var MapRouteRefForwardingFunction = ({
593
+ feature,
594
+ glow = 0.72,
595
+ id,
596
+ progress = 1,
597
+ strokeColor = "#006cff",
598
+ strokeWidth = 9,
599
+ durationInFrames,
600
+ from,
601
+ trimBefore,
602
+ freeze,
603
+ hidden,
604
+ name,
605
+ showInTimeline,
606
+ controls
607
+ }, ref) => {
608
+ const refForOutline = useRef3(null);
609
+ useImperativeHandle3(ref, () => refForOutline.current, []);
610
+ return /* @__PURE__ */ jsxs2(Sequence3, {
611
+ layout: "none",
612
+ from: from ?? 0,
613
+ trimBefore,
614
+ durationInFrames: durationInFrames ?? Infinity,
615
+ freeze,
616
+ hidden,
617
+ name: name ?? `<${feature.properties.name}>`,
618
+ showInTimeline: showInTimeline ?? true,
619
+ controls,
620
+ outlineRef: refForOutline,
621
+ children: [
622
+ /* @__PURE__ */ jsx3(MapRouteDrawing, {
623
+ feature,
624
+ glow,
625
+ id,
626
+ progress,
627
+ strokeColor,
628
+ strokeWidth
629
+ }),
630
+ /* @__PURE__ */ jsx3(MapRouteBounds, {
631
+ feature,
632
+ refForOutline
633
+ })
634
+ ]
635
+ });
636
+ };
637
+ var MapRouteInner = forwardRef3(MapRouteRefForwardingFunction);
638
+ var MapRoute = Interactive3.withSchema({
639
+ Component: MapRouteInner,
640
+ componentName: "<MapRoute>",
641
+ componentIdentity: null,
642
+ schema: mapRouteSchema,
643
+ supportsEffects: false
644
+ });
645
+ // src/MapViewport.tsx
646
+ import { Map as MapTilerMap, MapStyle } from "@maptiler/sdk";
647
+ import"@maptiler/sdk/style.css";
648
+ import {
649
+ forwardRef as forwardRef4,
650
+ useEffect as useEffect3,
651
+ useImperativeHandle as useImperativeHandle4,
652
+ useMemo as useMemo3,
653
+ useRef as useRef4,
654
+ useState as useState3
655
+ } from "react";
656
+ import {
657
+ Interactive as Interactive4,
658
+ Sequence as Sequence4,
659
+ useDelayRender as useDelayRender3
660
+ } from "remotion";
661
+ import { jsx as jsx4, jsxs as jsxs3, Fragment } from "react/jsx-runtime";
662
+ var mapViewportSchema = {
663
+ ...Interactive4.baseSchema,
664
+ centerLongitude: {
665
+ type: "number",
666
+ min: -180,
667
+ max: 180,
668
+ step: 0.0001,
669
+ default: 0,
670
+ description: "Center longitude",
671
+ hiddenFromList: false,
672
+ keyframable: true
673
+ },
674
+ centerLatitude: {
675
+ type: "number",
676
+ min: -90,
677
+ max: 90,
678
+ step: 0.0001,
679
+ default: 0,
680
+ description: "Center latitude",
681
+ hiddenFromList: false,
682
+ keyframable: true
683
+ },
684
+ zoom: {
685
+ type: "number",
686
+ min: 0,
687
+ max: 22,
688
+ step: 0.01,
689
+ default: 4,
690
+ description: "Zoom",
691
+ hiddenFromList: false,
692
+ keyframable: true
693
+ },
694
+ bearing: {
695
+ type: "number",
696
+ min: -360,
697
+ max: 360,
698
+ step: 1,
699
+ default: 0,
700
+ description: "Bearing",
701
+ hiddenFromList: false,
702
+ keyframable: true
703
+ },
704
+ backgroundColor: {
705
+ type: "color",
706
+ default: "#dfe7e2",
707
+ description: "Background color"
708
+ }
709
+ };
710
+ var MissingApiKey = () => {
711
+ return /* @__PURE__ */ jsxs3("div", {
712
+ style: {
713
+ alignItems: "center",
714
+ color: "#171a1f",
715
+ display: "flex",
716
+ flexDirection: "column",
717
+ fontFamily: "Arial, sans-serif",
718
+ inset: 0,
719
+ justifyContent: "center",
720
+ padding: 100,
721
+ position: "absolute",
722
+ textAlign: "center"
723
+ },
724
+ children: [
725
+ /* @__PURE__ */ jsx4("div", {
726
+ style: { fontSize: 64, fontWeight: 700 },
727
+ children: "MapTiler key needed"
728
+ }),
729
+ /* @__PURE__ */ jsx4("div", {
730
+ style: { fontSize: 32, lineHeight: 1.4, marginTop: 24 },
731
+ children: "Pass an apiKey prop to <MapViewport>."
732
+ })
733
+ ]
734
+ });
735
+ };
736
+ var MapViewportRefForwardingFunction = ({
737
+ apiKey,
738
+ backgroundColor = "#dfe7e2",
739
+ bearing = 0,
740
+ centerLatitude = 0,
741
+ centerLongitude = 0,
742
+ children,
743
+ durationInFrames,
744
+ from,
745
+ trimBefore,
746
+ freeze,
747
+ hidden,
748
+ name,
749
+ showInTimeline,
750
+ zoom = 4,
751
+ controls
752
+ }, ref) => {
753
+ const mapContainerRef = useRef4(null);
754
+ const mapRef = useRef4(null);
755
+ const viewportRef = useRef4(null);
756
+ const initialCameraRef = useRef4({
757
+ bearing,
758
+ centerLatitude,
759
+ centerLongitude,
760
+ zoom
761
+ });
762
+ const { continueRender, delayRender } = useDelayRender3();
763
+ const [map, setMap] = useState3(null);
764
+ const [cameraRevision, setCameraRevision] = useState3(0);
765
+ const [loadingHandle] = useState3(() => delayRender("Loading MapTiler map"));
766
+ const contextValue = useMemo3(() => ({ cameraRevision, map }), [cameraRevision, map]);
767
+ useImperativeHandle4(ref, () => viewportRef.current, []);
768
+ useEffect3(() => {
769
+ if (!apiKey) {
770
+ continueRender(loadingHandle);
771
+ return;
772
+ }
773
+ if (!mapContainerRef.current || mapRef.current) {
774
+ return;
775
+ }
776
+ const initialCamera = initialCameraRef.current;
777
+ const mapInstance = new MapTilerMap({
778
+ apiKey,
779
+ bearing: initialCamera.bearing,
780
+ canvasContextAttributes: { preserveDrawingBuffer: true },
781
+ center: [initialCamera.centerLongitude, initialCamera.centerLatitude],
782
+ container: mapContainerRef.current,
783
+ fadeDuration: 0,
784
+ fullscreenControl: false,
785
+ geolocateControl: false,
786
+ interactive: false,
787
+ navigationControl: false,
788
+ scaleControl: false,
789
+ style: MapStyle.BASIC,
790
+ terrainControl: false,
791
+ zoom: initialCamera.zoom
792
+ });
793
+ mapRef.current = mapInstance;
794
+ mapInstance.on("load", () => {
795
+ for (const layer of [...mapInstance.getStyle().layers ?? []]) {
796
+ if (layer.type === "symbol" || /other border/i.test(layer.id)) {
797
+ mapInstance.removeLayer(layer.id);
798
+ }
799
+ }
800
+ mapInstance.once("idle", () => {
801
+ setMap(mapInstance);
802
+ continueRender(loadingHandle);
803
+ });
804
+ mapInstance.triggerRepaint();
805
+ });
806
+ return () => {
807
+ mapInstance.remove();
808
+ mapRef.current = null;
809
+ };
810
+ }, [apiKey, continueRender, loadingHandle]);
811
+ useEffect3(() => {
812
+ if (!map) {
813
+ return;
814
+ }
815
+ const currentCenter = map.getCenter();
816
+ const cameraIsCurrent = Math.abs(currentCenter.lng - centerLongitude) < 0.0000001 && Math.abs(currentCenter.lat - centerLatitude) < 0.0000001 && Math.abs(map.getZoom() - zoom) < 0.0000001 && Math.abs(map.getBearing() - bearing) < 0.0000001;
817
+ if (cameraIsCurrent) {
818
+ return;
819
+ }
820
+ const cameraHandle = delayRender("Updating MapTiler camera");
821
+ let hasFinished = false;
822
+ const finish = () => {
823
+ if (hasFinished) {
824
+ return;
825
+ }
826
+ hasFinished = true;
827
+ continueRender(cameraHandle);
828
+ };
829
+ const onIdle = () => finish();
830
+ map.once("idle", onIdle);
831
+ map.jumpTo({
832
+ bearing,
833
+ center: [centerLongitude, centerLatitude],
834
+ zoom
835
+ });
836
+ setCameraRevision((revision) => revision + 1);
837
+ map.triggerRepaint();
838
+ return () => {
839
+ map.off("idle", onIdle);
840
+ finish();
841
+ };
842
+ }, [
843
+ bearing,
844
+ centerLatitude,
845
+ centerLongitude,
846
+ continueRender,
847
+ delayRender,
848
+ map,
849
+ zoom
850
+ ]);
851
+ return /* @__PURE__ */ jsx4(Sequence4, {
852
+ layout: "none",
853
+ from: from ?? 0,
854
+ trimBefore,
855
+ durationInFrames: durationInFrames ?? Infinity,
856
+ freeze,
857
+ hidden,
858
+ name: name ?? "<MapViewport>",
859
+ showInTimeline: showInTimeline ?? true,
860
+ controls,
861
+ children: /* @__PURE__ */ jsx4("div", {
862
+ ref: viewportRef,
863
+ style: {
864
+ backgroundColor,
865
+ inset: 0,
866
+ overflow: "hidden",
867
+ position: "absolute"
868
+ },
869
+ children: apiKey ? /* @__PURE__ */ jsxs3(Fragment, {
870
+ children: [
871
+ /* @__PURE__ */ jsx4("div", {
872
+ ref: mapContainerRef,
873
+ style: {
874
+ inset: 0,
875
+ position: "absolute"
876
+ }
877
+ }),
878
+ /* @__PURE__ */ jsx4(MapTilerContext.Provider, {
879
+ value: contextValue,
880
+ children
881
+ })
882
+ ]
883
+ }) : /* @__PURE__ */ jsx4(MissingApiKey, {})
884
+ })
885
+ });
886
+ };
887
+ var MapViewportInner = forwardRef4(MapViewportRefForwardingFunction);
888
+ var MapViewport = Interactive4.withSchema({
889
+ Component: MapViewportInner,
890
+ componentName: "<MapViewport>",
891
+ componentIdentity: null,
892
+ schema: mapViewportSchema,
893
+ supportsEffects: false
894
+ });
895
+ export {
896
+ MapViewport,
897
+ MapRoute,
898
+ MapRegion,
899
+ MapOverlay
900
+ };
@@ -0,0 +1,4 @@
1
+ export { MapOverlay } from './MapOverlay';
2
+ export { MapRegion, type MapRegionFeature } from './MapRegion';
3
+ export { MapRoute, type MapRouteFeature } from './MapRoute';
4
+ export { MapViewport } from './MapViewport';
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@remotion/maptiler",
3
+ "version": "4.0.514",
4
+ "description": "MapTiler components for Remotion",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "module": "dist/esm/index.mjs",
8
+ "repository": {
9
+ "url": "https://github.com/remotion-dev/remotion/tree/main/packages/maptiler"
10
+ },
11
+ "type": "module",
12
+ "scripts": {
13
+ "formatting": "oxfmt src --check",
14
+ "format": "oxfmt src",
15
+ "lint": "eslint src",
16
+ "watch": "tsgo -w",
17
+ "make": "tsgo && bun --env-file=../.env.bundle bundle.ts"
18
+ },
19
+ "author": "Jonny Burger <jonny@remotion.dev>",
20
+ "contributors": [],
21
+ "license": "Remotion License",
22
+ "bugs": {
23
+ "url": "https://github.com/remotion-dev/remotion/issues"
24
+ },
25
+ "dependencies": {
26
+ "@maptiler/sdk": "4.0.2",
27
+ "@turf/turf": "7.3.2",
28
+ "remotion": "4.0.514"
29
+ },
30
+ "peerDependencies": {
31
+ "react": ">=16.8.0",
32
+ "react-dom": ">=16.8.0"
33
+ },
34
+ "exports": {
35
+ ".": {
36
+ "types": "./dist/index.d.ts",
37
+ "module": "./dist/esm/index.mjs",
38
+ "import": "./dist/esm/index.mjs"
39
+ },
40
+ "./package.json": "./package.json"
41
+ },
42
+ "devDependencies": {
43
+ "react": "19.2.3",
44
+ "react-dom": "19.2.3",
45
+ "@remotion/eslint-config-internal": "4.0.514",
46
+ "eslint": "9.19.0",
47
+ "@typescript/native-preview": "7.0.0-dev.20260217.1"
48
+ },
49
+ "keywords": [
50
+ "remotion",
51
+ "maptiler"
52
+ ],
53
+ "publishConfig": {
54
+ "access": "public"
55
+ }
56
+ }