@maptiler/sdk 3.2.2 → 3.3.0-rc3

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
@@ -40,30 +40,30 @@ In addition to the details and examples provided in this readme, check out the [
40
40
  **Recommended for:** advanced applications
41
41
 
42
42
  ```ts
43
- import { config, Map } from '@maptiler/sdk';
43
+ import * as maptilersdk from '@maptiler/sdk';
44
44
 
45
45
  // Add your MapTiler Cloud API key to the config
46
46
  // (Go to https://cloud.maptiler.com/account/keys/ to get one for free!)
47
- config.apiKey = 'YOUR_API_KEY';
47
+ maptilersdk.config.apiKey = 'YOUR_API_KEY';
48
48
 
49
49
  // Let's say you have a DIV ready to receive a map
50
50
  const mapContainer = document.getElementById('my-container-div');
51
51
 
52
52
  // Instantiate the map
53
- const map = new Map({
53
+ const map = new maptilersdk.Map({
54
54
  container: mapContainer,
55
55
  });
56
56
  ```
57
57
 
58
58
  Alternatively, the `apiKey` can be set as Map option instead of in the `config` object. Yet, this will still internally propagate to the `config` object:
59
59
  ```ts
60
- import { Map } from '@maptiler/sdk';
60
+ import * as maptilersdk from '@maptiler/sdk';
61
61
 
62
62
  // Let's say you have a DIV ready to receive a map
63
63
  const mapContainer = document.getElementById('my-container-div');
64
64
 
65
65
  // Instantiate the map
66
- const map = new Map({
66
+ const map = new maptilersdk.Map({
67
67
  container: mapContainer,
68
68
  apiKey: 'YOUR_API_KEY'
69
69
  });
@@ -540,7 +540,125 @@ map.on("terrainAnimationStop", (e) => {
540
540
  });
541
541
  });
542
542
  ```
543
+ # Halo and Space Options
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
543
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.
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@typescript-eslint/utils/dist/ts-eslint").FlatConfig.ConfigArray;
2
+ export default _default;