@maptiler/sdk 3.4.0-rc2 → 3.4.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/.husky/pre-commit +2 -2
- package/README.md +133 -155
- package/dist/eslint.mjs +133 -0
- package/dist/maptiler-sdk.d.ts +2 -0
- package/dist/maptiler-sdk.mjs +12640 -0
- package/dist/maptiler-sdk.mjs.map +1 -0
- package/dist/src/ColorRamp.d.ts +359 -0
- package/dist/src/MLAdapters/AttributionControl.d.ts +5 -0
- package/dist/src/MLAdapters/BoxZoomHandler.d.ts +7 -0
- package/dist/src/MLAdapters/CanvasSource.d.ts +5 -0
- package/dist/src/MLAdapters/CooperativeGesturesHandler.d.ts +5 -0
- package/dist/src/MLAdapters/FullscreenControl.d.ts +5 -0
- package/dist/src/MLAdapters/GeoJSONSource.d.ts +5 -0
- package/dist/src/MLAdapters/GeolocateControl.d.ts +5 -0
- package/dist/src/MLAdapters/ImageSource.d.ts +5 -0
- package/dist/src/MLAdapters/KeyboardHandler.d.ts +5 -0
- package/dist/src/MLAdapters/LogoControl.d.ts +5 -0
- package/dist/src/MLAdapters/MapMouseEvent.d.ts +5 -0
- package/dist/src/MLAdapters/MapTouchEvent.d.ts +5 -0
- package/dist/src/MLAdapters/MapWheelEvent.d.ts +5 -0
- package/dist/src/MLAdapters/Marker.d.ts +5 -0
- package/dist/src/MLAdapters/NavigationControl.d.ts +5 -0
- package/dist/src/MLAdapters/Popup.d.ts +5 -0
- package/dist/src/MLAdapters/RasterDEMTileSource.d.ts +5 -0
- package/dist/src/MLAdapters/RasterTileSource.d.ts +5 -0
- package/dist/src/MLAdapters/ScaleControl.d.ts +5 -0
- package/dist/src/MLAdapters/ScrollZoomHandler.d.ts +5 -0
- package/dist/src/MLAdapters/Style.d.ts +5 -0
- package/dist/src/MLAdapters/TerrainControl.d.ts +5 -0
- package/dist/src/MLAdapters/TwoFingersTouchPitchHandler.d.ts +5 -0
- package/dist/src/MLAdapters/VectorTileSource.d.ts +5 -0
- package/dist/src/MLAdapters/VideoSource.d.ts +5 -0
- package/dist/src/Map.d.ts +424 -0
- package/dist/src/Point.d.ts +177 -0
- package/dist/src/Telemetry.d.ts +21 -0
- package/dist/src/caching.d.ts +4 -0
- package/dist/src/config.d.ts +85 -0
- package/dist/src/constants/defaults.d.ts +15 -0
- package/dist/src/controls/MaptilerGeolocateControl.d.ts +21 -0
- package/dist/src/controls/MaptilerLogoControl.d.ts +19 -0
- package/dist/src/controls/MaptilerNavigationControl.d.ts +17 -0
- package/dist/src/controls/MaptilerProjectionControl.d.ts +14 -0
- package/dist/src/controls/MaptilerTerrainControl.d.ts +16 -0
- package/dist/src/controls/Minimap.d.ts +57 -0
- package/dist/src/controls/index.d.ts +6 -0
- package/dist/src/converters/index.d.ts +1 -0
- package/dist/src/converters/xml.d.ts +54 -0
- package/dist/src/custom-layers/CubemapLayer/CubemapLayer.d.ts +216 -0
- package/dist/src/custom-layers/CubemapLayer/constants.d.ts +3 -0
- package/dist/src/custom-layers/CubemapLayer/index.d.ts +2 -0
- package/dist/src/custom-layers/CubemapLayer/loadCubemapTexture.d.ts +41 -0
- package/dist/src/custom-layers/CubemapLayer/types.d.ts +67 -0
- package/dist/src/custom-layers/RadialGradientLayer/RadialGradientLayer.d.ts +128 -0
- package/dist/src/custom-layers/RadialGradientLayer/index.d.ts +2 -0
- package/dist/src/custom-layers/RadialGradientLayer/types.d.ts +50 -0
- package/dist/src/custom-layers/extractCustomLayerStyle.d.ts +17 -0
- package/dist/src/custom-layers/index.d.ts +5 -0
- package/dist/src/helpers/index.d.ts +5 -0
- package/dist/src/helpers/screenshot.d.ts +18 -0
- package/dist/src/helpers/stylehelper.d.ts +28 -0
- package/dist/src/helpers/vectorlayerhelpers.d.ts +508 -0
- package/dist/src/index.d.ts +89 -0
- package/dist/src/language.d.ts +107 -0
- package/dist/src/mapstyle.d.ts +17 -0
- package/dist/src/tools.d.ts +84 -0
- package/dist/src/types.d.ts +1 -0
- package/dist/src/utils/dom.d.ts +2 -0
- package/dist/src/utils/geo-utils.d.ts +6 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/math-utils.d.ts +8 -0
- package/dist/src/utils/webgl-utils.d.ts +49 -0
- package/eslint.config.mjs +5 -5
- package/package.json +18 -15
- package/tsconfig.json +12 -7
- package/typedoc.json +2 -3
- package/e2e/global.d.ts +0 -12
- package/e2e/public/animated-route.geojson +0 -82
- package/e2e/public/animatedRouteLayer.html +0 -24
- package/e2e/public/mapLoad.html +0 -24
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-0-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-1-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-10-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-11-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-12-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-13-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-14-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-15-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-16-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-17-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-18-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-19-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-2-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-3-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-4-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-5-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-6-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-7-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-8-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/AnimatedRouteLayer.test.ts-snapshots/animated-route-9-chromium-darwin.png +0 -0
- package/e2e/snapshots/tests/map-load.test.ts-snapshots/mapLoad-chromium-darwin.png +0 -0
- package/e2e/tests/AnimatedRouteLayer.test.ts +0 -45
- package/e2e/tests/consts.ts +0 -0
- package/e2e/tests/expected-results/animatedRouteLayer-1.json +0 -202
- package/e2e/tests/helpers/fetchGeojson.ts +0 -21
- package/e2e/tests/helpers/getMapInstanceForFixture.ts +0 -86
- package/e2e/tests/map-load.test.ts +0 -14
- package/e2e/tests/mocks/maptiler-style.json +0 -27
- package/e2e/tests/mocks/tile.png +0 -0
- package/e2e/tsconfig.json +0 -10
- package/playwright.config.ts +0 -82
- package/vite.config-dev.ts +0 -34
- package/vite.config-e2e.ts +0 -13
- package/vite.config-es.ts +0 -53
- package/vite.config-test.ts +0 -17
- package/vite.config-umd.ts +0 -37
package/.husky/pre-commit
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
npx lint-staged;
|
|
2
|
-
|
|
3
|
-
npm run
|
|
2
|
+
npx ts-typecheck;
|
|
3
|
+
npm run test;
|
package/README.md
CHANGED
|
@@ -32,12 +32,7 @@ npm install --save @maptiler/sdk
|
|
|
32
32
|
⚠️ Please keep in mind that if you use any additional [MapTiler modules](https://docs.maptiler.com/sdk-js/modules/), you must update them to a version that supports MapTiler SDK JS v3.
|
|
33
33
|
|
|
34
34
|
# API documentation
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Full api typedoc documentation can also be generated via the commands:
|
|
38
|
-
|
|
39
|
-
`npm run docs:md` to generate markdown in `docs`
|
|
40
|
-
`npm run docs:html` to generate html docs in `docs-html`
|
|
35
|
+
In addition to the details and examples provided in this readme, check out the [complete API documentation](https://docs.maptiler.com/sdk-js/api/)
|
|
41
36
|
|
|
42
37
|
# Quick start
|
|
43
38
|
|
|
@@ -160,6 +155,7 @@ The SDK hosted on our CDN is bundled as *[Universal Module Definition](https://g
|
|
|
160
155
|
</script>
|
|
161
156
|
</body>
|
|
162
157
|
</html>
|
|
158
|
+
|
|
163
159
|
```
|
|
164
160
|
|
|
165
161
|
Check out the minimalist code samples in the [demos](demos) directory.
|
|
@@ -545,7 +541,138 @@ map.on("terrainAnimationStop", (e) => {
|
|
|
545
541
|
});
|
|
546
542
|
});
|
|
547
543
|
```
|
|
544
|
+
# Halo and Space Options
|
|
545
|
+
|
|
546
|
+
The `halo` and `space` options allow for enhanced visual customization of the map, especially for globe projections.
|
|
547
|
+
|
|
548
|
+
## `halo` (Atmospheric Glow)
|
|
549
|
+
The `halo` option adds a gradient-based atmospheric glow around the globe, simulating the visual effect of Earth's atmosphere when viewed from space.
|
|
550
|
+
|
|
551
|
+
### Usage:
|
|
552
|
+
You can enable a simple halo by setting it to `true`:
|
|
553
|
+
```ts
|
|
554
|
+
const map = new maptilersdk.Map({
|
|
555
|
+
container: document.getElementById("map"),
|
|
556
|
+
style: maptilersdk.MapStyle.OUTDOOR,
|
|
557
|
+
halo: true,
|
|
558
|
+
});
|
|
559
|
+
```
|
|
560
|
+
For more customization, you can define a radial gradient with scale and stops:
|
|
561
|
+
```ts
|
|
562
|
+
|
|
563
|
+
const map = new maptilersdk.Map({
|
|
564
|
+
container: document.getElementById("map"),
|
|
565
|
+
style: maptilersdk.MapStyle.OUTDOOR,
|
|
566
|
+
halo: {
|
|
567
|
+
scale: 1.5, // Controls the halo size
|
|
568
|
+
stops: [
|
|
569
|
+
[0.2, "transparent"],
|
|
570
|
+
[0.2, "red"],
|
|
571
|
+
[0.4, "red"],
|
|
572
|
+
[0.4, "transparent"],
|
|
573
|
+
[0.6, "transparent"],
|
|
574
|
+
[0.6, "red"],
|
|
575
|
+
[0.8, "red"],
|
|
576
|
+
[0.8, "transparent"],
|
|
577
|
+
[1.0, "transparent"],
|
|
578
|
+
],
|
|
579
|
+
},
|
|
580
|
+
});
|
|
581
|
+
```
|
|
582
|
+
You can also set the halo dynamically after the map loads:
|
|
583
|
+
```ts
|
|
584
|
+
map.on("load", () => {
|
|
585
|
+
map.setHalo({
|
|
586
|
+
scale: 2,
|
|
587
|
+
stops: [
|
|
588
|
+
[0.0, "rgba(135,206,250,1)"],
|
|
589
|
+
[0.5, "rgba(0,0,250,0.75)"],
|
|
590
|
+
[0.75, "rgba(250,0,0,0.0)"],
|
|
591
|
+
],
|
|
592
|
+
});
|
|
593
|
+
});
|
|
594
|
+
```
|
|
595
|
+
## `space` (Background Environment)
|
|
548
596
|
|
|
597
|
+
The space option allows customizing the background environment of the globe, simulating deep space or skybox effects.
|
|
598
|
+
### Usage
|
|
599
|
+
|
|
600
|
+
You can enable a simple space background with a solid color:
|
|
601
|
+
```ts
|
|
602
|
+
const map = new maptilersdk.Map({
|
|
603
|
+
container: document.getElementById("map"),
|
|
604
|
+
style: maptilersdk.MapStyle.OUTDOOR,
|
|
605
|
+
space: {
|
|
606
|
+
color: "#111122", // Dark space-like color
|
|
607
|
+
},
|
|
608
|
+
});
|
|
609
|
+
```
|
|
610
|
+
Alternatively, you can provide a cubemap for a space backround using one of the following methods:
|
|
611
|
+
|
|
612
|
+
#### Predefined Presets:
|
|
613
|
+
|
|
614
|
+
- `space`: Dark blue hsl(210, 100%, 4%) background and white stars (transparent background image). Space color changes the background color, stars always stay white.
|
|
615
|
+
- `stars` (default): Black background (image mask), space color changes the stars color, background always stays black.
|
|
616
|
+
- `milkyway`: Black half-transparent background with standard milkyway and stars. Space color changes the stars and milkyway color, background always stays black.
|
|
617
|
+
- `milkyway-subtle`: Black half-transparent background with subtle milkyway and less stars. Space color changes the stars and milkyway color, background always stays black.Black half-transparent background with standard milkyway and stars. Space color changes the stars and milkyway color, background always stays black.
|
|
618
|
+
- `milkyway-bright`: Black half-transparent background with bright milkyway and more stars. Space color changes the stars and milkyway color, background always stays black.
|
|
619
|
+
|
|
620
|
+
```ts
|
|
621
|
+
const map = new maptilersdk.Map({
|
|
622
|
+
container: document.getElementById("map"),
|
|
623
|
+
style: maptilersdk.MapStyle.OUTDOOR,
|
|
624
|
+
space: {
|
|
625
|
+
preset: "space",
|
|
626
|
+
},
|
|
627
|
+
});
|
|
628
|
+
```
|
|
629
|
+
#### Cubemap Images (Custom Skybox):
|
|
630
|
+
```ts
|
|
631
|
+
const map = new maptilersdk.Map({
|
|
632
|
+
container: document.getElementById("map"),
|
|
633
|
+
style: maptilersdk.MapStyle.OUTDOOR,
|
|
634
|
+
space: {
|
|
635
|
+
faces: {
|
|
636
|
+
nX: '/path-to-image/nX.png',
|
|
637
|
+
nY: '/path-to-image/nY.png',
|
|
638
|
+
nZ: '/path-to-image/nZ.png',
|
|
639
|
+
pX: '/path-to-image/pX.png',
|
|
640
|
+
pY: '/path-to-image/pY.png',
|
|
641
|
+
pZ: '/path-to-image/pZ.png',
|
|
642
|
+
},
|
|
643
|
+
},
|
|
644
|
+
});
|
|
645
|
+
```
|
|
646
|
+
#### Cubemap Path with image format
|
|
647
|
+
|
|
648
|
+
This fetches all images from a path, this assumes all files are named px, nx, py, ny, pz, nz and suffixed with the appropriate extension specified in `format`.
|
|
649
|
+
```ts
|
|
650
|
+
const map = new maptilersdk.Map({
|
|
651
|
+
container: document.getElementById("map"),
|
|
652
|
+
style: maptilersdk.MapStyle.OUTDOOR,
|
|
653
|
+
space: {
|
|
654
|
+
path: {
|
|
655
|
+
baseUrl: "spacebox/transparent",
|
|
656
|
+
format: "png", // Defaults to PNG
|
|
657
|
+
},
|
|
658
|
+
},
|
|
659
|
+
});
|
|
660
|
+
```
|
|
661
|
+
#### Set the space background dynamically:
|
|
662
|
+
```ts
|
|
663
|
+
map.on("load", () => {
|
|
664
|
+
map.setSpace({
|
|
665
|
+
color: "red",
|
|
666
|
+
path: {
|
|
667
|
+
baseUrl: "spacebox/transparent",
|
|
668
|
+
},
|
|
669
|
+
});
|
|
670
|
+
});
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
Note: if `space.color` or `space.<faces | path | preset>` are not explicitly set in the call to `setSpace`, then the previous value will remain for this field.
|
|
674
|
+
|
|
675
|
+
Further code examples can be found in `~/demos/`
|
|
549
676
|
|
|
550
677
|
# Easy language switching
|
|
551
678
|
The language generally depends on the style but we made it possible to easily set and update from a built-in list of languages.
|
|
@@ -1114,155 +1241,6 @@ Turning off *zoom compensation* allows for more accurate adjustments to the visu
|
|
|
1114
1241
|
All the other options are documented on [our reference page](https://docs.maptiler.com/sdk-js/api/helpers/#heatmap) and more examples are available [here](https://docs.maptiler.com/sdk-js/examples/?q=heatmap+helper).
|
|
1115
1242
|
|
|
1116
1243
|
# Other helpers
|
|
1117
|
-
|
|
1118
|
-
## Camera routes and animations
|
|
1119
|
-
|
|
1120
|
-
The SDK comes with several classes to help with animations, particularly route animations.
|
|
1121
|
-
|
|
1122
|
-
See `demos/07-animated-routes.html` for examples.
|
|
1123
|
-
|
|
1124
|
-
### 🧩 `MaptilerAnimation`
|
|
1125
|
-
|
|
1126
|
-
MaptilerAnimation is a utility class for smoothly animating between keyframes using custom easing and playback control. It supports event-based hooks for frame updates and completion, and works well within rendering loops or UI transitions.
|
|
1127
|
-
|
|
1128
|
-
#### 🚀 Usage
|
|
1129
|
-
|
|
1130
|
-
```ts
|
|
1131
|
-
// linearly animated between values
|
|
1132
|
-
const animation = new MaptilerAnimation({
|
|
1133
|
-
keyframes: [
|
|
1134
|
-
// `props` are interpolated across the duration
|
|
1135
|
-
{ delta: 0, props: { lon: -7.445, } },
|
|
1136
|
-
// `userData` can hold any type of custom data to pass with the keyframe
|
|
1137
|
-
{ delta: 0.5, userData: { mydata: "whoa!" } },
|
|
1138
|
-
{ delta: 1, props: { lon: -7.455 } }
|
|
1139
|
-
],
|
|
1140
|
-
duration: 1000, // 1 second
|
|
1141
|
-
iterations: Infinity // loop forever
|
|
1142
|
-
});
|
|
1143
|
-
|
|
1144
|
-
const marker = new Marker().setLngLat(
|
|
1145
|
-
new LngLat(
|
|
1146
|
-
-7.449346225791231,
|
|
1147
|
-
39.399728941536836,
|
|
1148
|
-
)
|
|
1149
|
-
).addTo(map);
|
|
1150
|
-
|
|
1151
|
-
// TimeUpdate is fired every frame
|
|
1152
|
-
animation.addEventListener(AnimationEventTypes.TimeUpdate, (e) => {
|
|
1153
|
-
marker.setLngLat(
|
|
1154
|
-
new LngLat(
|
|
1155
|
-
e.props.lon,
|
|
1156
|
-
39.399728941536836,
|
|
1157
|
-
)
|
|
1158
|
-
)
|
|
1159
|
-
})
|
|
1160
|
-
// fired when the keyframe changes
|
|
1161
|
-
animation.addEventListener(AnimationEventTypes.Keyframe, ({ userData }) => {
|
|
1162
|
-
console.log(userData.mydata) // "whoa!"
|
|
1163
|
-
});
|
|
1164
|
-
|
|
1165
|
-
animation.play();
|
|
1166
|
-
```
|
|
1167
|
-

|
|
1168
|
-
|
|
1169
|
-
```ts
|
|
1170
|
-
// eased between values
|
|
1171
|
-
const animation = new MaptilerAnimation({
|
|
1172
|
-
keyframes: [
|
|
1173
|
-
// `props` are interpolated across the duration
|
|
1174
|
-
{ delta: 0, easing: EasingFunctionName.ElasticInOut, props: { lon: -7.445, } },
|
|
1175
|
-
{ delta: 1, props: { lon: -7.455 } }
|
|
1176
|
-
],
|
|
1177
|
-
duration: 1000, // 1 second
|
|
1178
|
-
iterations: Infinity // loop forever
|
|
1179
|
-
});
|
|
1180
|
-
```
|
|
1181
|
-

|
|
1182
|
-
|
|
1183
|
-
### 🗺️ `AnimatedRouteLayer`
|
|
1184
|
-
|
|
1185
|
-
`AnimatedRouteLayer` is custom layer that animates a path or route on the map based on keyframes or GeoJSON data. It supports animated line styling and camera following, making it ideal for visualizing routes, playback tracks, or timeline-based geographic events.
|
|
1186
|
-
|
|
1187
|
-
Note: At present, to avoid problems arising from the camera being manipulated by two animatioons at any one time, there can only ever be one instance of `AnimatedRouteLayer` on the map at any time. This API may change in the future, but at present you must remove each instance of `AnimatedRouteLayer` from the map before adding another.
|
|
1188
|
-
|
|
1189
|
-
#### ✨ Features
|
|
1190
|
-
- Animate a path using keyframes or GeoJSON data
|
|
1191
|
-
- Optional animated stroke styles to indicate progress
|
|
1192
|
-
- Camera movement smoothing, following along the route
|
|
1193
|
-
- Configurable duration, easing, delay, and iterations via geojson properties
|
|
1194
|
-
- Event-based lifecycle hooks for adaptibility.
|
|
1195
|
-
- Optional manual frame advancement (e.g., for scrubbing or syncing with map events, scroll etc etc)
|
|
1196
|
-
|
|
1197
|
-
#### 🚀 Basic Usage
|
|
1198
|
-
```ts
|
|
1199
|
-
const myGeoJSONSource = {
|
|
1200
|
-
"type": "FeatureCollection",
|
|
1201
|
-
"features": [
|
|
1202
|
-
{
|
|
1203
|
-
"type": "Feature",
|
|
1204
|
-
"geometry": {
|
|
1205
|
-
"type": "LineString",
|
|
1206
|
-
"coordinates": [
|
|
1207
|
-
[-74.0060, 40.7128],
|
|
1208
|
-
[-73.9352, 40.7306],
|
|
1209
|
-
[-73.9851, 40.7580]
|
|
1210
|
-
]
|
|
1211
|
-
},
|
|
1212
|
-
"properties": {
|
|
1213
|
-
"@duration": 5000, // animation params are prepended with '@'
|
|
1214
|
-
"@iterations": 3,
|
|
1215
|
-
"@delay": 1000,
|
|
1216
|
-
"@autoplay": true,
|
|
1217
|
-
"bearing": [
|
|
1218
|
-
40,
|
|
1219
|
-
30,
|
|
1220
|
-
10,
|
|
1221
|
-
10,
|
|
1222
|
-
20,
|
|
1223
|
-
40,
|
|
1224
|
-
]
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
]
|
|
1228
|
-
}
|
|
1229
|
-
|
|
1230
|
-
const animatedRoute = new AnimatedRouteLayer({
|
|
1231
|
-
source: {
|
|
1232
|
-
// assumes that the source is already added to the map with the given layer ID
|
|
1233
|
-
id: "my-geojson-source", // the name of the source
|
|
1234
|
-
layerID: "route-layer", // the name of the layer
|
|
1235
|
-
featureSetIndex: 0, // the index of the featureset within the geojson
|
|
1236
|
-
},
|
|
1237
|
-
// OR
|
|
1238
|
-
keyframes: [], // an array of keyframes
|
|
1239
|
-
|
|
1240
|
-
duration: 5000,
|
|
1241
|
-
pathStrokeAnimation: {
|
|
1242
|
-
// will only be appliued to LineString GeoJSON types
|
|
1243
|
-
activeColor: [0, 128, 0, 1], // color of the line that has already been traversed
|
|
1244
|
-
inactiveColor: [128, 128, 128, 0.5],
|
|
1245
|
-
},
|
|
1246
|
-
cameraAnimation: {
|
|
1247
|
-
follow: true, // should the camera follow the route?
|
|
1248
|
-
pathSmoothing: {
|
|
1249
|
-
resolution: 20, // the resolution of the smoothness
|
|
1250
|
-
epsilon: 10, // how much the path is simplified before smoothing
|
|
1251
|
-
},
|
|
1252
|
-
},
|
|
1253
|
-
autoplay: true,
|
|
1254
|
-
});
|
|
1255
|
-
|
|
1256
|
-
// Add to map
|
|
1257
|
-
map.addLayer(animatedRoute);
|
|
1258
|
-
|
|
1259
|
-
// Playback controls
|
|
1260
|
-
animatedRoute.play();
|
|
1261
|
-
animatedRoute.pause();
|
|
1262
|
-
```
|
|
1263
|
-
|
|
1264
|
-
For a full example of how to use this, look at [the example](./demos/07-animated-routes.html)
|
|
1265
|
-
|
|
1266
1244
|
## Convert GPX and KML to GeoJSON
|
|
1267
1245
|
In the [Polyline helper section](#polyline-layer-helper) above, we have seen that one can feed the helper directly with a path to a GPX or KML file, that is then converted under the hood client-side into a GeoJSON `FeatureCollection` object. This conversion feature is also exposed and can be used as such:
|
|
1268
1246
|
|
package/dist/eslint.mjs
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
|
|
3
|
+
import tseslint from "typescript-eslint";
|
|
4
|
+
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
|
|
5
|
+
|
|
6
|
+
export default tseslint.config(
|
|
7
|
+
// https://typescript-eslint.io/getting-started/typed-linting/
|
|
8
|
+
tseslint.configs.strictTypeChecked,
|
|
9
|
+
tseslint.configs.stylisticTypeChecked,
|
|
10
|
+
tseslint.configs.recommendedTypeChecked,
|
|
11
|
+
{
|
|
12
|
+
// forked from https://www.npmjs.com/package/eslint-plugin-restrict-imports
|
|
13
|
+
plugins: {
|
|
14
|
+
import: {
|
|
15
|
+
rules: {
|
|
16
|
+
"default-imports-only": {
|
|
17
|
+
meta: {
|
|
18
|
+
type: "suggestion",
|
|
19
|
+
docs: {},
|
|
20
|
+
schema: [
|
|
21
|
+
{
|
|
22
|
+
bannedImport: {
|
|
23
|
+
locations: ["filePaths"],
|
|
24
|
+
message: "string",
|
|
25
|
+
fixedLocation: "string",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
create: function (context) {
|
|
31
|
+
const filePath = context.getFilename();
|
|
32
|
+
const options = context.options[0] || {
|
|
33
|
+
"^/(.*)": {
|
|
34
|
+
locations: ["(.*)"],
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
ImportDeclaration: (node) => {
|
|
40
|
+
Object.entries(options).forEach(([bannedImport, config]) => {
|
|
41
|
+
const importLocationRegex = new RegExp(bannedImport);
|
|
42
|
+
|
|
43
|
+
if (config.ignoreTypeImports && node.importKind === "type") return;
|
|
44
|
+
|
|
45
|
+
if (importLocationRegex.test(node.source.value)) {
|
|
46
|
+
config.locations.forEach((fp) => {
|
|
47
|
+
const bannedLocationRegex = new RegExp(fp);
|
|
48
|
+
|
|
49
|
+
if (bannedLocationRegex.test(filePath)) {
|
|
50
|
+
node.specifiers.forEach((specifier) => {
|
|
51
|
+
if (specifier.type !== "ImportDefaultSpecifier") {
|
|
52
|
+
context.report({
|
|
53
|
+
// @ts-expect-error `message` seems to work with this...
|
|
54
|
+
message: config.message ?? `Importing from '${bannedImport}' is banned in '${fp}'`,
|
|
55
|
+
node,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
rules: {
|
|
71
|
+
"import/default-imports-only": [
|
|
72
|
+
"error",
|
|
73
|
+
{
|
|
74
|
+
"maplibre-gl$": {
|
|
75
|
+
locations: ["^(?!.*\.d\.ts$).*\.((ts|js))$"],
|
|
76
|
+
message: `Maplibre-gl uses CJS modules, only default imports are supported, named imports may fail on some setups.`,
|
|
77
|
+
ignoreTypeImports: true,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
languageOptions: {
|
|
85
|
+
parserOptions: {
|
|
86
|
+
projectService: true,
|
|
87
|
+
tsconfigRootDir: import.meta.dirname,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
// https://github.com/prettier/eslint-plugin-prettier
|
|
92
|
+
eslintPluginPrettierRecommended,
|
|
93
|
+
//
|
|
94
|
+
{
|
|
95
|
+
rules: {
|
|
96
|
+
"@typescript-eslint/array-type": "off",
|
|
97
|
+
"@typescript-eslint/consistent-indexed-object-style": "warn",
|
|
98
|
+
"@typescript-eslint/consistent-type-definitions": "off",
|
|
99
|
+
"@typescript-eslint/no-base-to-string": "warn",
|
|
100
|
+
"@typescript-eslint/no-confusing-void-expression": "warn",
|
|
101
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
102
|
+
"@typescript-eslint/no-empty-function": "warn", // this is to satisfy maplibre-gl custom layer interface
|
|
103
|
+
"@typescript-eslint/no-floating-promises": "warn",
|
|
104
|
+
"@typescript-eslint/no-inferrable-types": "off",
|
|
105
|
+
"@typescript-eslint/no-misused-promises": "warn",
|
|
106
|
+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "off",
|
|
107
|
+
"@typescript-eslint/no-unnecessary-condition": "warn",
|
|
108
|
+
"@typescript-eslint/no-unnecessary-type-arguments": "off",
|
|
109
|
+
"@typescript-eslint/no-unnecessary-type-assertion": "off",
|
|
110
|
+
"@typescript-eslint/no-unnecessary-type-parameters": "off", // as we are a lib, types serve as documentation
|
|
111
|
+
"@typescript-eslint/no-unused-vars": "warn",
|
|
112
|
+
"@typescript-eslint/no-unsafe-argument": "warn",
|
|
113
|
+
"@typescript-eslint/no-unsafe-assignment": "warn",
|
|
114
|
+
"@typescript-eslint/no-unsafe-call": "warn",
|
|
115
|
+
"@typescript-eslint/no-unsafe-enum-comparison": "off",
|
|
116
|
+
"@typescript-eslint/no-unsafe-member-access": "warn",
|
|
117
|
+
"@typescript-eslint/no-unsafe-return": "warn",
|
|
118
|
+
"@typescript-eslint/no-non-null-assertion": "warn",
|
|
119
|
+
"@typescript-eslint/non-nullable-type-assertion-style": "warn",
|
|
120
|
+
"@typescript-eslint/prefer-for-of": "off",
|
|
121
|
+
"@typescript-eslint/prefer-nullish-coalescing": "warn",
|
|
122
|
+
"@typescript-eslint/prefer-optional-chain": "off",
|
|
123
|
+
"@typescript-eslint/prefer-return-this-type": "off",
|
|
124
|
+
"@typescript-eslint/prefer-string-starts-ends-with": "warn",
|
|
125
|
+
"@typescript-eslint/restrict-plus-operands": "warn",
|
|
126
|
+
"@typescript-eslint/restrict-template-expressions": "warn",
|
|
127
|
+
"@typescript-eslint/related-getter-setter-pairs": "off",
|
|
128
|
+
"@typescript-eslint/unbound-method": "warn",
|
|
129
|
+
"@typescript-eslint/use-unknown-in-catch-callback-variable": "warn",
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
//
|
|
133
|
+
);
|