@maptiler/sdk 3.4.1 → 3.5.0-rc1

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 CHANGED
@@ -1,2 +1,3 @@
1
1
  npx lint-staged;
2
+ npx ts-typecheck;
2
3
  npm run test;
package/README.md CHANGED
@@ -541,7 +541,139 @@ map.on("terrainAnimationStop", (e) => {
541
541
  });
542
542
  });
543
543
  ```
544
+ # Halo and Space Options
544
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)
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
+ - `milkyway-colored`: Full background image with natural space colors. Space color doesn’t change anything (non transparent image).
620
+
621
+ ```ts
622
+ const map = new maptilersdk.Map({
623
+ container: document.getElementById("map"),
624
+ style: maptilersdk.MapStyle.OUTDOOR,
625
+ space: {
626
+ preset: "space",
627
+ },
628
+ });
629
+ ```
630
+ #### Cubemap Images (Custom Skybox):
631
+ ```ts
632
+ const map = new maptilersdk.Map({
633
+ container: document.getElementById("map"),
634
+ style: maptilersdk.MapStyle.OUTDOOR,
635
+ space: {
636
+ faces: {
637
+ nX: '/path-to-image/nX.png',
638
+ nY: '/path-to-image/nY.png',
639
+ nZ: '/path-to-image/nZ.png',
640
+ pX: '/path-to-image/pX.png',
641
+ pY: '/path-to-image/pY.png',
642
+ pZ: '/path-to-image/pZ.png',
643
+ },
644
+ },
645
+ });
646
+ ```
647
+ #### Cubemap Path with image format
648
+
649
+ 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`.
650
+ ```ts
651
+ const map = new maptilersdk.Map({
652
+ container: document.getElementById("map"),
653
+ style: maptilersdk.MapStyle.OUTDOOR,
654
+ space: {
655
+ path: {
656
+ baseUrl: "spacebox/transparent",
657
+ format: "png", // Defaults to PNG
658
+ },
659
+ },
660
+ });
661
+ ```
662
+ #### Set the space background dynamically:
663
+ ```ts
664
+ map.on("load", () => {
665
+ map.setSpace({
666
+ color: "red",
667
+ path: {
668
+ baseUrl: "spacebox/transparent",
669
+ },
670
+ });
671
+ });
672
+ ```
673
+
674
+ 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.
675
+
676
+ Further code examples can be found in `~/demos/`
545
677
 
546
678
  # Easy language switching
547
679
  The language generally depends on the style but we made it possible to easily set and update from a built-in list of languages.