@maptiler/sdk 3.1.0 → 3.3.0-rc2
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 +1 -0
- package/README.md +118 -0
- package/dist/maptiler-sdk.mjs +3241 -2092
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/src/Map.d.ts +20 -1
- package/dist/src/custom-layers/CubemapLayer/CubemapLayer.d.ts +29 -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 +6 -0
- package/dist/src/custom-layers/CubemapLayer/types.d.ts +37 -0
- package/dist/src/custom-layers/RadialGradientLayer/RadialGradientLayer.d.ts +23 -0
- package/dist/src/custom-layers/RadialGradientLayer/index.d.ts +2 -0
- package/dist/src/custom-layers/RadialGradientLayer/types.d.ts +11 -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 +13 -3
- package/dist/src/utils/geo-utils.d.ts +6 -0
- package/dist/src/utils/math-utils.d.ts +4 -0
- package/dist/src/utils/webgl-utils.d.ts +49 -0
- package/eslint.config.mjs +1 -1
- package/package.json +8 -1
package/.husky/pre-commit
CHANGED
package/README.md
CHANGED
|
@@ -540,7 +540,125 @@ map.on("terrainAnimationStop", (e) => {
|
|
|
540
540
|
});
|
|
541
541
|
});
|
|
542
542
|
```
|
|
543
|
+
# Halo and Space Options
|
|
543
544
|
|
|
545
|
+
The `halo` and `space` options allow for enhanced visual customization of the map, especially for globe projections.
|
|
546
|
+
|
|
547
|
+
## `halo` (Atmospheric Glow)
|
|
548
|
+
The `halo` option adds a gradient-based atmospheric glow around the globe, simulating the visual effect of Earth's atmosphere when viewed from space.
|
|
549
|
+
|
|
550
|
+
### Usage:
|
|
551
|
+
You can enable a simple halo by setting it to `true`:
|
|
552
|
+
```ts
|
|
553
|
+
const map = new maptilersdk.Map({
|
|
554
|
+
container: document.getElementById("map"),
|
|
555
|
+
style: maptilersdk.MapStyle.OUTDOOR,
|
|
556
|
+
halo: true,
|
|
557
|
+
});
|
|
558
|
+
```
|
|
559
|
+
For more customization, you can define a radial gradient with scale and stops:
|
|
560
|
+
```ts
|
|
561
|
+
|
|
562
|
+
const map = new maptilersdk.Map({
|
|
563
|
+
container: document.getElementById("map"),
|
|
564
|
+
style: maptilersdk.MapStyle.OUTDOOR,
|
|
565
|
+
halo: {
|
|
566
|
+
scale: 1.5, // Controls the halo size
|
|
567
|
+
stops: [
|
|
568
|
+
[0.2, "transparent"],
|
|
569
|
+
[0.2, "red"],
|
|
570
|
+
[0.4, "red"],
|
|
571
|
+
[0.4, "transparent"],
|
|
572
|
+
[0.6, "transparent"],
|
|
573
|
+
[0.6, "red"],
|
|
574
|
+
[0.8, "red"],
|
|
575
|
+
[0.8, "transparent"],
|
|
576
|
+
[1.0, "transparent"],
|
|
577
|
+
],
|
|
578
|
+
},
|
|
579
|
+
});
|
|
580
|
+
```
|
|
581
|
+
You can also set the halo dynamically after the map loads:
|
|
582
|
+
```ts
|
|
583
|
+
map.on("load", () => {
|
|
584
|
+
map.setHalo({
|
|
585
|
+
scale: 2,
|
|
586
|
+
stops: [
|
|
587
|
+
[0.0, "rgba(135,206,250,1)"],
|
|
588
|
+
[0.5, "rgba(0,0,250,0.75)"],
|
|
589
|
+
[0.75, "rgba(250,0,0,0.0)"],
|
|
590
|
+
],
|
|
591
|
+
});
|
|
592
|
+
});
|
|
593
|
+
```
|
|
594
|
+
## `space` (Background Environment)
|
|
595
|
+
|
|
596
|
+
The space option allows customizing the background environment of the globe, simulating deep space or skybox effects.
|
|
597
|
+
### Usage
|
|
598
|
+
|
|
599
|
+
You can enable a simple space background with a solid color:
|
|
600
|
+
```ts
|
|
601
|
+
const map = new maptilersdk.Map({
|
|
602
|
+
container: document.getElementById("map"),
|
|
603
|
+
style: maptilersdk.MapStyle.OUTDOOR,
|
|
604
|
+
space: {
|
|
605
|
+
color: "#111122", // Dark space-like color
|
|
606
|
+
},
|
|
607
|
+
});
|
|
608
|
+
```
|
|
609
|
+
Alternatively, you can provide a cubemap for a realistic skybox effect using one of the following methods:
|
|
610
|
+
|
|
611
|
+
Predefined Presets:
|
|
612
|
+
```ts
|
|
613
|
+
const map = new maptilersdk.Map({
|
|
614
|
+
container: document.getElementById("map"),
|
|
615
|
+
style: maptilersdk.MapStyle.OUTDOOR,
|
|
616
|
+
space: {
|
|
617
|
+
preset: "universe-dark",
|
|
618
|
+
},
|
|
619
|
+
});
|
|
620
|
+
```
|
|
621
|
+
Cubemap Images (Custom Skybox):
|
|
622
|
+
```ts
|
|
623
|
+
const map = new maptilersdk.Map({
|
|
624
|
+
container: document.getElementById("map"),
|
|
625
|
+
style: maptilersdk.MapStyle.OUTDOOR,
|
|
626
|
+
space: {
|
|
627
|
+
faces: {
|
|
628
|
+
pX: '/path-to-image/pX.png',
|
|
629
|
+
nX: '/path-to-image/nX.png',
|
|
630
|
+
pY: '/path-to-image/pY.png',
|
|
631
|
+
nY: '/path-to-image/nY.png',
|
|
632
|
+
pZ: '/path-to-image/pZ.png',
|
|
633
|
+
nZ: '/path-to-image/nZ.png',
|
|
634
|
+
},
|
|
635
|
+
},
|
|
636
|
+
});
|
|
637
|
+
```
|
|
638
|
+
Cubemap Path with image format, 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`.
|
|
639
|
+
```ts
|
|
640
|
+
const map = new maptilersdk.Map({
|
|
641
|
+
container: document.getElementById("map"),
|
|
642
|
+
style: maptilersdk.MapStyle.OUTDOOR,
|
|
643
|
+
space: {
|
|
644
|
+
path: {
|
|
645
|
+
baseUrl: "spacebox/transparent",
|
|
646
|
+
format: "png", // Defaults to PNG
|
|
647
|
+
},
|
|
648
|
+
},
|
|
649
|
+
});
|
|
650
|
+
```
|
|
651
|
+
You can also set the space background dynamically:
|
|
652
|
+
```ts
|
|
653
|
+
map.on("load", () => {
|
|
654
|
+
map.setSpace({
|
|
655
|
+
color: "red",
|
|
656
|
+
path: {
|
|
657
|
+
baseUrl: "spacebox/transparent",
|
|
658
|
+
},
|
|
659
|
+
});
|
|
660
|
+
});
|
|
661
|
+
```
|
|
544
662
|
|
|
545
663
|
# Easy language switching
|
|
546
664
|
The language generally depends on the style but we made it possible to easily set and update from a built-in list of languages.
|