@maptiler/sdk 2.0.2 → 2.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maptiler/sdk",
3
- "version": "2.0.2",
3
+ "version": "2.1.0",
4
4
  "description": "The Javascript & TypeScript map SDK tailored for MapTiler Cloud",
5
5
  "module": "dist/maptiler-sdk.mjs",
6
6
  "types": "dist/maptiler-sdk.d.ts",
@@ -77,7 +77,7 @@
77
77
  "@maptiler/client": "^1.8.1",
78
78
  "events": "^3.3.0",
79
79
  "js-base64": "^3.7.4",
80
- "maplibre-gl": "^4.1.3",
80
+ "maplibre-gl": "4.4.1",
81
81
  "uuid": "^9.0.0"
82
82
  }
83
83
  }
package/readme.md CHANGED
@@ -30,7 +30,7 @@ npm install --save @maptiler/sdk
30
30
  ```
31
31
 
32
32
  # API documentation
33
- In addition to the details and examples provided in this readme, check out the [complete API documentation](https://maptiler.github.io/maptiler-sdk-js) (see the [Markdown version](docsmd/README.md))
33
+ In addition to the details and examples provided in this readme, check out the [complete API documentation](https://docs.maptiler.com/sdk-js/api/)
34
34
 
35
35
  # Quick start
36
36
 
@@ -53,7 +53,7 @@ const map = new maptilersdk.Map({
53
53
  });
54
54
  ```
55
55
 
56
- Alternativelly, the `apiKey` can be set as Map option intead of in the `config` object. Yet, this will still internally propagate to the `config` object:
56
+ 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:
57
57
  ```ts
58
58
  import * as maptilersdk from '@maptiler/sdk';
59
59
 
@@ -69,7 +69,7 @@ const map = new maptilersdk.Map({
69
69
 
70
70
  By default, the map will be initialized with the style [streets-v2](https://www.maptiler.com/maps/#style=streets-v2).
71
71
 
72
- Depending on the framework and environment your are using for your application, you will have to also include the CSS file.
72
+ Depending on the framework and environment you are using for your application, you will have to also include the CSS file.
73
73
 
74
74
  For example, with a [NextJS](https://nextjs.org/) app, this can take place at the top of the file `_app.ts/js`:
75
75
  ```ts
@@ -78,9 +78,9 @@ import "@maptiler/sdk/dist/maptiler-sdk.css";
78
78
 
79
79
 
80
80
  ## With CDN
81
- The SDK hosted on our CDN is bundled as *[Universal Module Definition](https://github.com/umdjs/umd)* (UMD) to make it standalone and containing all its dependencies. The CDN also serves the style sheet (css).
81
+ The SDK hosted on our CDN is bundled as *[Universal Module Definition](https://github.com/umdjs/umd)* (UMD) to make it standalone and contain all its dependencies. The CDN also serves the style sheet (CSS).
82
82
 
83
- **Recommended for:** simple map intergration example and demos
83
+ **Recommended for:** simple map integration example and demos
84
84
 
85
85
  ```html
86
86
  <html>
@@ -123,11 +123,12 @@ The SDK hosted on our CDN is bundled as *[Universal Module Definition](https://g
123
123
  </body>
124
124
  </html>
125
125
  ```
126
- Checkout the minimalist code samples in the [demos](demos) directory.
126
+
127
+ Check out the minimalist code samples in the [demos](demos) directory.
127
128
 
128
129
 
129
130
  # Many styles to choose from
130
- MapTiler teams maintains a few styles that we have decided to expose from the SDK. This has two advantages:
131
+ MapTiler teams maintain a few styles that we have decided to expose from the SDK. This has two advantages:
131
132
  - they are easier to remember, no need to type along style URL
132
133
  - if we make an update to a style, you will benefit from it without modifying your codebase
133
134
 
@@ -160,7 +161,7 @@ The styles with a shorthand provided by the SDK are the following:
160
161
  <details>
161
162
  <summary>Know more about built-in map styles</summary>
162
163
 
163
- MapTiler provides some **reference styles** as well as some **variants** for each. A **reference syle** sets some guidelines about what kind of information is displayed, the granularity of the information, and more generaly defines a purpose for which this style is the most relevant: street navigation, outdoor adventure, minimalist dashboard, etc. Then, each **reference style** offers a range of **variants** that contain the same level of information and has the same purpose but using different colors schemes.
164
+ MapTiler provides some **reference styles** as well as some **variants** for each. A **reference style** sets some guidelines about what kind of information is displayed, the granularity of the information, and more generally defines a purpose for which this style is the most relevant: street navigation, outdoor adventure, minimalist dashboard, etc. Then, each **reference style** offers a range of **variants** that contain the same level of information and have the same purpose but use different color schemes.
164
165
 
165
166
  Here is the full list:
166
167
  - `MapStyle.STREETS`, reference style for navigation and city exploration
@@ -180,7 +181,7 @@ Here is the full list:
180
181
  - `MapStyle.BASIC` reference style for minimalist design and general purpose
181
182
  - `MapStyle.BASIC.DARK` (variant)
182
183
  - `MapStyle.BASIC.LIGHT` (variant)
183
- - `MapStyle.BRIGHT` reference style for high contrast navigation
184
+ - `MapStyle.BRIGHT` reference style for high-contrast navigation
184
185
  - `MapStyle.BRIGHT.DARK` (variant)
185
186
  - `MapStyle.BRIGHT.LIGHT` (variant)
186
187
  - `MapStyle.BRIGHT.PASTEL` (variant)
@@ -199,13 +200,13 @@ Here is the full list:
199
200
  - `MapStyle.OPENSTREETMAP` (reference style, this one does not have any variants)
200
201
 
201
202
 
202
- All reference styles (instances of `ReferenceMapStyle`) and style variants (instances of `MapStyleVariant`) have methods to know the alternative styles and variant that belong to the same reference style (`.getVariants()`). This is handy to provide a default/dark/light alternative color scheme, yet preserving the same level of details as in the reference style. Read more about about [ReferenceMapStyle](docsmd/classes/ReferenceMapStyle.md) and [MapStyleVariant](docsmd/classes/MapStyleVariant.md).
203
+ All reference styles (instances of `ReferenceMapStyle`) and style variants (instances of `MapStyleVariant`) have methods to know the alternative styles and variants that belong to the same reference style (`.getVariants()`). This is handy to provide a default/dark/light alternative color scheme, yet preserving the same level of details as in the reference style. Read more about about [ReferenceMapStyle](https://docs.maptiler.com/sdk-js/api/map-styles/#referencemapstyle) and [MapStyleVariant](https://docs.maptiler.com/sdk-js/api/map-styles/#mapstylevariant).
203
204
  </details>
204
205
 
205
206
  ___
206
207
 
207
208
 
208
- Still, you can still use some classic styles with just a *string* if you know their MapTiler CLoud ID:
209
+ Still, you can still use some classic styles with just a *string* if you know their MapTiler Cloud ID:
209
210
 
210
211
  ```ts
211
212
  map.setStyle('outdoor-v2');
@@ -230,8 +231,8 @@ map.setStyle("maptiler://c912ffc8-2360-487a-973b-59d037fb15b8");
230
231
  ```
231
232
 
232
233
  # Centering the map on visitors
233
- It is sometimes handy to center map on the visitor's location, and there are multiple ways of doing it but for the SDK, we have decided to make this extra simple by using the [IP geolocation](#%EF%B8%8F%EF%B8%8F-geolocation) API provided by [MapTiler Cloud](https://docs.maptiler.com/cloud/api/geolocation/), directly exposed as a single option of the `Map` constructor. There are two strategies:
234
- 1. `POINT`: centering the map on the actual visitor location, optionnaly using the `zoom` option (zoom level `13` if none is provided). As a more precise option, if the user has previously granted access to the browser location (more precise) then this is going to be used.
234
+ It is sometimes handy to center the map on the visitor's location, and there are multiple ways of doing it but for the SDK, we have decided to make this extra simple by using the [IP geolocation](#%EF%B8%8F%EF%B8%8F-geolocation) API provided by [MapTiler Cloud](https://docs.maptiler.com/cloud/api/geolocation/), directly exposed as a single option of the `Map` constructor. There are two strategies:
235
+ 1. `POINT`: centering the map on the actual visitor location, optionally using the `zoom` option (zoom level `13` if none is provided). As a more precise option, if the user has previously granted access to the browser location (more precise) then this is going to be used.
235
236
  2. `COUNTRY`: fitting the map view on the bounding box of the visitor's country. In this case, the `zoom` option, if provided, will be ignored
236
237
 
237
238
  Here is how the map gets centered on the visitor's location:
@@ -253,21 +254,21 @@ new maptilersdk.Map({
253
254
  ```
254
255
 
255
256
  The `geolocation` options will not be taken into consideration in the following cases:
256
- - if the `center` options is provided, then it prevails
257
- - if the `hash` options is provided with the value `true` **AND** a location hash is already part of the URL. If `hash` is `true` but there is not yet a location hash in the URL, then the geolocation will work.
257
+ - if the `center` option is provided, then it prevails
258
+ - if the `hash` option is provided with the value `true` **AND** a location hash is already part of the URL. If `hash` is `true` but there is not yet a location hash in the URL, then the geolocation will work.
258
259
 
259
260
  > đŸ“Ŗ *__Note:__* if none of the options `center` or `hash` is provided to the `Map` constructor, then the map will be centered using the `POINT` strategy, unless the `geolocate` has the value `false`.
260
261
 
261
262
  > đŸ“Ŗ *__Note 2:__* the term *IP geolocation* refers to finding the physical location of a computer using its *IP address*. The *IP address* is a numerical identifier of a computer within a network, just like the phone number for a telephone. The *IP geolocation* is **not** using the GPS of a device and usually provides a precision in the order of a few hundred meters. This precision may vary based on many local parameters such as the density of the network grid or the terrain, this is why it is generaly better not to use a zoom level higher than `14`.
262
263
 
263
264
  # Easy to add controls
264
- The term "control" is commonly used for all sorts of buttons and information display that take place in one of the corner of the map area. The most well know are probably the `[+]` and `[-]` zoom buttons as well as the attribution information. Plenty of others are possible and we have made a few easy to add and directly accessible from the `Map` constructor options:
265
+ The term "control" is commonly used for all sorts of buttons and information displays that take place in one of the corners of the map area. The most well-known are probably the `[+]` and `[-]` zoom buttons as well as the attribution information. Plenty of others are possible and we have made a few easy to add and directly accessible from the `Map` constructor options:
265
266
 
266
267
  - `navigationControl`
267
268
  - Shows the `[+]`, `[-]` and tilt/bearing/compass buttons
268
269
  - a boolean or a corner position. Showing on the top-right by default. Hidden if `false`.
269
270
  - `geolocateControl`
270
- - Shows a arrow-shaped locate button. When clicked, it adds a marker and center the map. If clicked again, the marker disapears (unless the map was moved since first clicked)
271
+ - Shows an arrow-shaped locate button. When clicked, it adds a marker and centers the map. If clicked again, the marker disappears (unless the map was moved since first clicked)
271
272
  - a boolean or a corner position. Showing on the top-right by default. Hidden if `false`.
272
273
  - `terrainControl`
273
274
  - Shows a button to enable/disable the 3D terrain (does not tilt the map)
@@ -306,7 +307,7 @@ const map = new Map({
306
307
  </p>
307
308
 
308
309
 
309
- You want to enable 3D terrain? That's easy now with a single function call:
310
+ Do you want to enable 3D terrain? That's easy now with a single function call:
310
311
  ```ts
311
312
  // With the default exaggeration factor of 1
312
313
  map.enableTerrain();
@@ -343,13 +344,13 @@ map.disableTerrain()
343
344
  # Easy language switching
344
345
  The language generally depends on the style but we made it possible to easily set and update from a built-in list of languages.
345
346
 
346
- The builtin list of supported languages is accessible from the `Language` object:
347
+ The built-in list of supported languages is accessible from the `Language` object:
347
348
  ```ts
348
349
  import { Language } from "@maptiler/sdk";
349
350
  ```
350
351
  In the UMD bundle, it will be directly at `maptilersdk.Language`.
351
352
 
352
- There three distinct ways to set the language of a map:
353
+ There are three distinct ways to set the language of a map:
353
354
 
354
355
  1. **Global way, using the config object:**
355
356
  ```ts
@@ -357,9 +358,9 @@ import { config } from "@maptiler/sdk";
357
358
 
358
359
  config.primaryLanguage = Language.ENGLISH;
359
360
  ```
360
- Then, the if any further language is setting is applied, all the map instances created afterward will use this language.
361
+ Then, if any further language setting is applied, all the map instances created afterward will use this language.
361
362
 
362
- 2. **Set the language at instanciation time:**
363
+ 2. **Set the language at instantiation time:**
363
364
  ```ts
364
365
  const map = new Map({
365
366
  // some options...
@@ -368,19 +369,19 @@ const map = new Map({
368
369
  ```
369
370
  It will only apply `ENGLISH` as the language of this specific map instance (and will not alter the global `config`).
370
371
 
371
- 3. **Set the language after the map has been instanciated:**
372
+ 3. **Set the language after the map has been instantiated:**
372
373
  ```ts
373
374
  map.setLanguage(Language.ENGLISH);
374
375
  ```
375
376
  Again, it will only apply `ENGLISH` as the language of this specific map instance (and will not alter the global `config`).
376
377
 
377
378
 
378
- The list of supported languages is built-in and can be found [here](src/language.ts). In addition, there are spacial language *flags*:
379
+ The list of supported languages is built-in and can be found [here](src/language.ts). In addition, there are special language *flags*:
379
380
  - `Language.AUTO` **[DEFAULT]** uses the language defined in the web browser
380
381
  - `Language.STYLE_LOCK` to strictly use the language defined in the style. Prevents any further language update
381
382
  - `Language.LOCAL` uses the language local to each country
382
- - `Language.LATIN` uses a default with latin characters
383
- - `Language.NON_LATIN` uses a default with non-latin characters
383
+ - `Language.LATIN` uses a default with Latin characters
384
+ - `Language.NON_LATIN` uses a default with non-Latin characters
384
385
 
385
386
  Whenever a label is not supported in the defined language, it falls back to `Language.LOCAL`.
386
387
 
@@ -388,7 +389,7 @@ Here is a sample of some compatible languages:
388
389
  ![](images/screenshots/multilang.gif)
389
390
 
390
391
  # Built-in support for right-to-left languages
391
- Languages that are written right-to-left such as arabic and hebrew are fully supported by default. No need to install any plugin!
392
+ Languages that are written right-to-left such as Arabic and Hebrew are fully supported by default. No need to install any plugins!
392
393
 
393
394
  <p align="center">
394
395
  <img src="images/screenshots/lang-arabic.jpeg" width="48%"></img>
@@ -398,10 +399,10 @@ Languages that are written right-to-left such as arabic and hebrew are fully sup
398
399
  # Custom Events and Map Lifecycle
399
400
  ## Events
400
401
  ### The `ready` event
401
- The `ready` event happens just after the `load` event but waits that all the controls managed by the `Map` constructor are dealt with, some having an asynchronous logic to set up.
402
- Since the `ready` event waits that all the basic controls are nicely positioned, it is **safer** to use `ready` than `load` if you plan to add other custom comtrols with the `.addControl()` method.
402
+ The `ready` event happens just after the `load` event but waits until all the controls managed by the `Map` constructor are dealt with, some having an asynchronous logic to set up.
403
+ Since the `ready` event waits until all the basic controls are nicely positioned, it is **safer** to use `ready` than `load` if you plan to add other custom controls with the `.addControl()` method.
403
404
 
404
- This event works exactely the same way as `load` and you can safely replace those by `"ready"`. Here is a usage example:
405
+ This event works exactly the same way as `load` and you can safely replace those by `"ready"`. Here is a usage example:
405
406
 
406
407
  ```js
407
408
  const map = new maptilersdk.Map({
@@ -418,7 +419,7 @@ map.on("ready", (evt) => {
418
419
  The `loadWithTerrain` event is triggered only *once* in a `Map` instance lifecycle, when both the `ready` event and the `terrain` event **with non-null terrain** are fired.
419
420
 
420
421
  **Why a new event?**
421
- When a map is instanciated with the option `terrain: true`, then MapTiler terrain is directly added to it and some animation functions such as `.flyTo()` or `.easeTo()` if started straight after the map initialization will actually need to wait a few milliseconds that the terrain is properly initialized before running.
422
+ When a map is instantiated with the option `terrain: true`, then MapTiler terrain is directly added to it and some animation functions such as `.flyTo()` or `.easeTo()` if started straight after the map initialization will actually need to wait a few milliseconds that the terrain is properly initialized before running.
422
423
  Relying on the `ready` or `load` event to run an animation with a map with terrain may fail in some cases for this reason, and this is why waiting for `loadWithTerrain` is safer in this particular situation.
423
424
 
424
425
  ## Lifecycle Methods
@@ -468,7 +469,7 @@ async function init() {
468
469
  }
469
470
  ```
470
471
 
471
- We deployed exactely the same logic for the `loadWithTerrain` event. Let's see how they two ways compares.
472
+ We deployed exactly the same logic for the `loadWithTerrain` event. Let's see how the two ways compare.
472
473
  - Classic: with a callback on the `loadWithTerrain` event:
473
474
  ```ts
474
475
  function init() {
@@ -565,11 +566,11 @@ We believe that the *promise* approach is better because it does not nest scopes
565
566
  > đŸ“Ŗ *__Note:__* Generally speaking, *promises* are not a go to replacement for all event+callback and are suitable only for events that are called only once in the lifecycle of a Map instance. This is the reason why we have decided to provide a *promise* equivalent only for the `load`, `ready` and `loadWithTerrain` events but not for events that may be called multiple time such as interaction events.
566
567
 
567
568
  # Color Ramps
568
- A color ramp is a color gradient defined in a specific interval, for instance in [0, 1], and for any value within this interval will retrieve a color. They are defined by at least a color at each bound and usualy additional colors within the range.
569
+ A color ramp is a color gradient defined in a specific interval, for instance in [0, 1], and for any value within this interval will retrieve a color. They are defined by at least a color at each bound and usually additional colors within the range.
569
570
 
570
571
  Color ramps are super useful to represent numerical data in a visual way: the temperature, the population density, the average commute time, etc.
571
572
 
572
- The SDK includes many built-in ready to use color ramps as well as extra logic to manipulate them and create new ones, here is the full list:
573
+ The SDK includes many built-in ready-to-use color ramps as well as extra logic to manipulate them and create new ones, here is the full list:
573
574
 
574
575
  ![](images/colorramps.png)
575
576
 
@@ -591,7 +592,7 @@ const zeroColorHex = temperatureTurbo.getColorHex(0);
591
592
  // The color is a string: "#2ddabdff"
592
593
  ```
593
594
 
594
- Creating a new one consists in defining all the colors for each *color stops*. The values can be in the range of interest and *do not* have to be in [0, 1]. For example, let's recreate a *Viridis* color ramp but with a range going from 0 to 100:
595
+ Creating a new one consists of defining all the colors for each *color stops*. The values can be in the range of interest and *do not* have to be in [0, 1]. For example, let's recreate a *Viridis* color ramp but with a range going from 0 to 100:
595
596
 
596
597
  ```ts
597
598
  import { ColorRamp } from "@maptiler/sdk";
@@ -611,13 +612,13 @@ const myCustomRamp = new ColorRamp({
611
612
  });
612
613
  ```
613
614
 
614
- When defining a new *ramp*, the colors can be a RGB array (`[number, number, number]`) or a RGBA array (`[number, number, number, number]`).
615
+ When defining a new *ramp*, the colors can be an RGB array (`[number, number, number]`) or an RGBA array (`[number, number, number, number]`).
615
616
 
616
- Many methods are available on color ramps, such as getting a `<canvas>` element of it, rescale it, flip it or [resample it in a non-linear way](colorramp.md). Read more on [our reference page](https://docs.maptiler.com/sdk-js/api/map/) and have a look at our [examples](https://docs.maptiler.com/sdk-js/examples/?q=colorramp) to see how they work.
617
+ Many methods are available on color ramps, such as getting the `<canvas>` element of it, rescaling it, flipping it or [resampling it in a non-linear way](colorramp.md). Read more on [our reference page](https://docs.maptiler.com/sdk-js/api/color-ramp/) and have a look at our [examples](https://docs.maptiler.com/sdk-js/examples/?q=colorramp) to see how they work.
617
618
 
618
619
 
619
620
  # Vector Layer Helpers
620
- **Let's make vector layers easy!** Originaly, you'd have to add a source and then proceed to the styling of your layer, which can be tricky because there are a lot of `paint` and `layout` options and they vary a lot from one type of layer to another. **But we have helpers for this!** đŸ–‹ī¸
621
+ **Let's make vector layers easy!** Originally, you'd have to add a source and then proceed to the styling of your layer, which can be tricky because there are a lot of `paint` and `layout` options and they vary a lot from one type of layer to another. **But we have helpers for this!** đŸ–‹ī¸
621
622
  ![](images/screenshots/point-layer.jpg)
622
623
 
623
624
  ## Shared logic
@@ -625,7 +626,7 @@ Helpers come with a lot of **built-in defaults** and some fail-proof logic that
625
626
 
626
627
  Depending on the type of feature to add (point, polyline, polygon or heatmap), a different helper function needs to be used, but datasource could contain mixed types of feature and the helper will only display a specific type.
627
628
 
628
- All the helpers are made avaialable under the `helpers` object. If you are using ES Modules, this is how you access them:
629
+ All the helpers are made available under the `helpers` object. If you are using ES Modules, this is how you access them:
629
630
  ```ts
630
631
  import { Map, helpers } from "@maptiler/sdk";
631
632
  ```
@@ -637,21 +638,21 @@ maptilersdk.helpers
637
638
 
638
639
  **Example:** we have a *geoJSON* file that contains both *polygons* and *point* and we use it as the `data` property on the `helpers.addPoint(map, { options })`, this will only add the *points*.
639
640
 
640
- In addition to easy styling, helper's datasource can be:
641
+ In addition to easy styling, the helper's datasource can be:
641
642
  - a URL to a geoJSON file or its string content
642
643
  - a URL to a GPX or KML file (only for the polyline helper) or its string content
643
644
  - a UUID of a MapTiler Cloud dataset
644
645
 
645
646
  ### Multiple Layers
646
- The key design principle of these vector layers helpers is **it's easy to make what you want**, which is very different from **making MapLibre easier to use**.
647
+ The key design principle of these vector layer helpers is **it's easy to make what you want**, which is very different from **making MapLibre easier to use**.
647
648
 
648
649
  > For example, to create a road with an outline, one must draw two layers: a wider base layer and a narrower top layer, fueled by the same polyline data. This requires ordering the layers properly and computing not the width of the outline, but rather the width of the polyline underneath so that it outgrows the top road layer of the desired number of pixels.
649
650
 
650
- With the polyline helper, you just say if you want an outline and specify its size (or even a zoom dependant size) and everything is handled for you. As a result, calling the method `helpers.addPolyline` will return an object with **multiple IDs**: ID of the top/main layer, ID of the outline layer (could be `null`) and the ID of the data source. This makes further layer and source manipulation possible.
651
+ With the polyline helper, you just say if you want an outline and specify its size (or even a zoom-dependent size) and everything is handled for you. As a result, calling the method `helpers.addPolyline` will return an object with **multiple IDs**: the ID of the top/main layer, the ID of the outline layer (could be `null`) and the ID of the data source. This makes further layer and source manipulation possible.
651
652
 
652
653
  ### Input
653
654
 
654
- The vector layer helper also share some *I/O* logic: each of them can take many options but a subset of them is common across all the helpers:
655
+ The vector layer helper also shares some *I/O* logic: each of them can take many options but a subset of them is common across all the helpers:
655
656
 
656
657
  ```ts
657
658
  /**
@@ -696,9 +697,9 @@ maxzoom?: number;
696
697
 
697
698
 
698
699
  ## Polyline Layer Helper
699
- The method `helpers.addPolyline` is not only compaptible with the traditional GeoJSON source but also with **GPX** and **KML** files and the `.data` options can be a MapTiler Cloud dataset UUID and will be resolved automatically.
700
+ The method `helpers.addPolyline` is not only compatible with the traditional GeoJSON source but also with **GPX** and **KML** files and the `.data` options can be a MapTiler Cloud dataset UUID and will be resolved automatically.
700
701
 
701
- here is the minimal usage, with the default line width and a random color (withing a selected list):
702
+ here is the minimal usage, with the default line width and a random color (within a selected list):
702
703
  ```ts
703
704
  helpers.addPolyline(map, {
704
705
  // A URL, relative or absolute
@@ -707,7 +708,7 @@ helpers.addPolyline(map, {
707
708
  ```
708
709
  ![](images/screenshots/default-trace.jpg)
709
710
 
710
- We can add many options, such a a specific color, a custom width or a dash pattern, this time sourcing the data from MapTiler Cloud, using the UUID of a dataset:
711
+ We can add many options, such as specific color, a custom width or a dash pattern, this time sourcing the data from MapTiler Cloud, using the UUID of a dataset:
711
712
  ```ts
712
713
  helpers.addPolyline(map, {
713
714
  data: "74003ba7-215a-4b7e-8e26-5bbe3aa70b05",
@@ -747,7 +748,7 @@ helpers.addPolyline(map, {
747
748
  ![](images/screenshots/polyline-glow.png)
748
749
 
749
750
 
750
- All the other options are documented on a [our reference page](https://docs.maptiler.com/sdk-js/api/map/) and more examples are available [here](https://docs.maptiler.com/sdk-js/examples/).
751
+ All the other options are documented on [our reference page](https://docs.maptiler.com/sdk-js/api/helpers/#polyline) and more examples are available [here](https://docs.maptiler.com/sdk-js/examples/?q=polyline+helper).
751
752
 
752
753
  ## Polygon Layer Helper
753
754
  The polygon helper makes it easy to create vector layers that contain polygons, whether they are *multi*polylons, *holed*polygons or just simple polygons. Whenever it's possible and it makes sense, we use the same terminology across the different helpers.
@@ -764,7 +765,7 @@ helpers.addPolygon(map, {
764
765
  Again, if no color is specified, a random one from a list is being picked:
765
766
  ![](images/screenshots/polygon-transparent.png)
766
767
 
767
- Plenty of options are available to create the interesting thematic visualizations:
768
+ Plenty of options are available to create interesting thematic visualizations:
768
769
 
769
770
  ```ts
770
771
  helpers.addPolygon(map, {
@@ -779,10 +780,10 @@ helpers.addPolygon(map, {
779
780
  ```
780
781
  ![](images/screenshots/swiss-cheese.png)
781
782
 
782
- All the other options are documented on a [our reference page](https://docs.maptiler.com/sdk-js/api/map/) and more examples are available [here](https://docs.maptiler.com/sdk-js/examples/).
783
+ All the other options are documented on [our reference page](https://docs.maptiler.com/sdk-js/api/helpers/#polygon) and more examples are available [here](https://docs.maptiler.com/sdk-js/examples/?q=polygon+helper).
783
784
 
784
785
  ## Point Layer Helper
785
- A point visualisation may appear like the simplest of all, but we noticed this is where people get the most creative: cluster, data-drive variable radius, but also scaled with zoom, with or without labels, data-driven colors, etc. Our helper supports all of these and will fill-in with built-in default for what's missing.
786
+ A point visualization may appear like the simplest of all, but we noticed this is where people get the most creative: cluster, data-driven variable radius, but also scaled with zoom, with or without labels, data-driven colors, etc. Our helper supports all of these and will fill-in with built-in default for what's missing.
786
787
 
787
788
  Here is the simplest example, with a dataset loaded from a local file:
788
789
  ```ts
@@ -803,7 +804,7 @@ helpers.addPoint(map, {
803
804
  On the other hand, if clusters are enabled, the default color is fueled by the color ramp `TURBO` scaled from `10` to `10000` non-linearly resampled with the method `"ease-out-square"`. The size also varies from `minPointradius` (default: `10`) to `maxPointRadius` (default: `50`):
804
805
  ![](images/screenshots/points-clustered.png)
805
806
 
806
- With the point helper, it's also possible to adapt the color and theradius based on a property. In the following example, we display a point for each public school, with the scaling factor being the number of students:
807
+ With the point helper, it's also possible to adapt the color and the radius based on a property. In the following example, we display a point for each public school, with the scaling factor being the number of students:
807
808
  ```ts
808
809
  helpers.addPoint(map, {
809
810
  data: "public-schools.geojson",
@@ -818,12 +819,12 @@ helpers.addPoint(map, {
818
819
  ```
819
820
  ![](images/screenshots/nyc-schools.png)
820
821
 
821
- Here, the`PORTLAND` color ramp is going to be used so that schools with `200` students or less will have the colors at the very begining of the color ramp and schools with `2000` or more will have the color defined at the very end. Schools in between will be attributed a colors in a non-linear fashion, following the `"ease-out-sqrt"` method (read **Color Ramps** section above for more info).
822
+ Here, the`PORTLAND` color ramp is going to be used so that schools with `200` students or less will have the colors at the very beginning of the color ramp and schools with `2000` or more will have the color defined at the very end. Schools in between will be attributed a color in a non-linear fashion, following the `"ease-out-sqrt"` method (read **Color Ramps** section above for more info).
822
823
 
823
- All the other options are documented on a [our reference page](https://docs.maptiler.com/sdk-js/api/map/) and more examples are available [here](https://docs.maptiler.com/sdk-js/examples/).
824
+ All the other options are documented on [our reference page](https://docs.maptiler.com/sdk-js/api/helpers/#point) and more examples are available [here](https://docs.maptiler.com/sdk-js/examples/?q=point+helper).
824
825
 
825
826
  ## Heatmap Layer Helper
826
- The heatmap layer is a great alternative for visualizing a collection of sparse data, but they can be challenging to use, especially when one has to come up with their own color ramp from scratch. **The helper makes this much easier!**
827
+ The heatmap layer is a great alternative for visualizing a collection of sparse data, but it can be challenging to use, especially when one has to come up with their own color ramp from scratch. **The helper makes this much easier!**
827
828
 
828
829
  Here is a minimalist example, using the default built-in `TURBO` color ramp:
829
830
  ```ts
@@ -833,7 +834,7 @@ helpers.addHeatmap(map, {
833
834
  ```
834
835
  ![](images/screenshots/heatmap-schools.png)
835
836
 
836
- Some visualisations are created with a fixed geographic extent or zoom level in mind, whether it's a survey at the scale of a single neigbohood, or statitics at country scale. In this case, we want to tailor the color, radius, weight and intensity of the heatmap blobs exactely for this precise settings. In the following example, we disable the *zoom compensation* to make sure radii and intensity is never zoom-dependant:
837
+ Some visualizations are created with a fixed geographic extent or zoom level in mind, whether it's a survey at the scale of a single neighborhood or statistics at a country scale. In this case, we want to tailor the color, radius, weight and intensity of the heatmap blobs exactly for these precise settings. In the following example, we disable the *zoom compensation* to make sure radio and intensity are never zoom-dependant:
837
838
  ```ts
838
839
  helpers.addHeatmap(map, {
839
840
  data: "public-schools.geojson",
@@ -859,12 +860,12 @@ helpers.addHeatmap(map, {
859
860
  ![](images/screenshots/heatmap-colorramp.png)
860
861
  Turning off *zoom compensation* allows for more accurate adjustments to the visualization at a specific zoom level, but it may not adapt as smoothly when zooming in or out.
861
862
 
862
- All the other options are documented on a [our reference page](https://docs.maptiler.com/sdk-js/api/map/) and more examples are available [here](https://docs.maptiler.com/sdk-js/examples/).
863
+ 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).
863
864
 
864
865
  # Caching
865
866
  Starting from v2, MapTiler SDK introduced the **caching** of tiles and fonts served by MapTiler Cloud, which can represent a large chunk of the data being fetched when browsing a map. This caching leverages modern browsers caching API so it's well-managed and there is no risk of bloating! When we update **MapTiler Planet** or our **official styles**, the caching logic will detect it and automatically invalidate older versions of the tiles that were previously cached.
866
867
 
867
- Caching greatly improves the performance at load time and positively impact the user experience, for this reason, it is **enabled by default**. If for debugging purposes or a for a very specific use-case caching needs to be disabled, then it possible:
868
+ Caching greatly improves the performance at load time and positively impacts the user experience, for this reason, it is **enabled by default**. If for debugging purposes or for a very specific use-case caching needs to be disabled, then it is possible:
868
869
 
869
870
  ```ts
870
871
  import { config } from "@maptiler/sdk";
@@ -873,7 +874,7 @@ config.caching = false;
873
874
  ```
874
875
 
875
876
  # Easy access to MapTiler Cloud API
876
- Our map SDK is not only about maps! We also provide plenty of wrapper to our API calls!
877
+ Our map SDK is not only about maps! We also provide plenty of wrappers to our API calls!
877
878
 
878
879
  > đŸ“Ŗ *__Note:__* If you need <ins>only the API Client library</ins> to use in a headless fashion and without any map display, check out out [API Client library](https://docs.maptiler.com/client-js/) for browser and NodeJS. It's exactely what is down below and only that, in a minimalistic [TypeScript package](https://github.com/maptiler/maptiler-client-js) 🐙.
879
880
 
@@ -895,7 +896,7 @@ You can provide some options such as:
895
896
  Read more about forward geocoding on our [official documentation](https://docs.maptiler.com/client-js/geocoding/#forward).
896
897
 
897
898
  ### Reverse
898
- You wan to tknow the name of a place, given a longitude-latitude? Use the reverse geocoding:
899
+ You want to know the name of a place, given a longitude-latitude? Use the reverse geocoding:
899
900
  ```ts
900
901
  // in an async function, or as a 'thenable':
901
902
  const result = await maptilersdk.geocoding.reverse([6.249638, 46.402056]);
@@ -905,7 +906,7 @@ The same option object as the forward geocoding can be provided.
905
906
  Read more about reverse geocoding on our [official documentation](https://docs.maptiler.com/client-js/geocoding/#reverse).
906
907
 
907
908
  ### Language
908
- For both *forward* and *reverse* geocoding, this library provides a list of supported languages as shorthands to [ISO language codes](https://en.wikipedia.org/wiki/ISO_639-1). The result will be provided in multiple languages if the `language` options is an array:
909
+ For both *forward* and *reverse* geocoding, this library provides a list of supported languages as shorthands to [ISO language codes](https://en.wikipedia.org/wiki/ISO_639-1). The result will be provided in multiple languages if the `language` option is an array:
909
910
 
910
911
  ```ts
911
912
  const result = await maptilersdk.geocoding.forward('paris', {language: [maptilersdk.geocoding.languages.SPANISH, maptilersdk.geocoding.languages.KOREAN]})
@@ -914,9 +915,9 @@ const result = await maptilersdk.geocoding.forward('paris', {language: [maptiler
914
915
  The special language `AUTO` will detect the platform/browser preferred language.
915
916
 
916
917
  ## đŸ•ĩī¸â€â™‚ī¸ Geolocation
917
- The geolocation service provides location informations of a visitor using its IP address.
918
+ The geolocation service provides location information of a visitor using its IP address.
918
919
 
919
- The geolocation uses the IP address of a visitors to provide informations about their location, such as city, region, country, timezone, etc. The precision is lower than GPS but does not require visitors to explicitely enable the location service from their web browser.
920
+ The geolocation uses the IP address of a visitor to provide information about their location, such as city, region, country, timezone, etc. The precision is lower than GPS but does not require visitors to explicitly enable the location service from their web browser.
920
921
 
921
922
  There is only a single function:
922
923
  ```ts
@@ -927,10 +928,10 @@ const result = await maptilersdk.geolocation.info();
927
928
  Read more about geolocation on our [official documentation](https://docs.maptiler.com/client-js/geolocation/).
928
929
 
929
930
  ## 🌐 Coordinates
930
- If you are already familiar with [epsg.io](https://epsg.io/) (created by MapTiler), then you may find convenient to access the details of more than 10 thousands of coordinate reference systems (CRS) programmatically, as well as transforming coordinates from one system to another!
931
+ If you are already familiar with [epsg.io](https://epsg.io/) (created by MapTiler), then you may find it convenient to access the details of more than 10 thousands coordinate reference systems (CRS) programmatically, as well as transform coordinates from one system to another!
931
932
 
932
933
  ### Search
933
- The `search` lets you perform a query in a free form fashion. Here are some examples:
934
+ The `search` lets you perform a query in a free-form fashion. Here are some examples:
934
935
  ```ts
935
936
  // in an async function, or as a 'thenable':
936
937
  const resultA = await maptilersdk.coordinates.search('mercator');
@@ -939,14 +940,14 @@ const resultC = await maptilersdk.coordinates.search('france');
939
940
  const resultD = await maptilersdk.coordinates.search('code:4326', {transformations: true}));
940
941
  ```
941
942
 
942
- The `transformations` options retrieves a lot more details about the CRS that MapTiler API is able to transform to/from than just their IDs.
943
+ The `transformations` options retrieve a lot more details about the CRS that MapTiler API is able to transform to/from than just their IDs.
943
944
 
944
945
  Read more about searching coordinate systems on our [official documentation](https://docs.maptiler.com/client-js/coordinates/#search).
945
946
 
946
947
  ### Transform
947
948
  Transforming a couple of coordinates from one system to another can be challenging, for example, most countries have their own official system, yet web mapping tools are more often than not exclusive to [WGS84](https://epsg.io/4326).
948
949
 
949
- If not provided, both the source (`sourceCrs`) and the destination (`targetCrs`) are default to **EPSG:4326** (in other words, [WGS84](https://epsg.io/4326)). Here is how to use this feature:
950
+ If not provided, both the source (`sourceCrs`) and the destination (`targetCrs) are defaulted to **EPSG:4326**** (in other words, [WGS84](https://epsg.io/4326)). Here is how to use this feature:
950
951
 
951
952
  ```ts
952
953
  // in an async function, or as a 'thenable':
@@ -961,7 +962,7 @@ const resultB = await maptilersdk.coordinates.transform([[10, 48], [1, 45]], {ta
961
962
  Read more about transforming coordinates on our [official documentation](https://docs.maptiler.com/client-js/coordinates/#transform).
962
963
 
963
964
  ## đŸ’Ŋ Data
964
- MapTiler Cloud give its users the possibility to [upload and create data](https://cloud.maptiler.com/data/), manually with a user interface or by uploading a GPX, GeoJSON, KML or shp file. A unique ID is associated to each dataset so that we can later on access it programmatically to retrieve a GeoJSON equivalent of it:
965
+ MapTiler Cloud gives its users the possibility to [upload and create data](https://cloud.maptiler.com/data/), manually with a user interface or by uploading a GPX, GeoJSON, KML or shp file. A unique ID is associated with each dataset so that we can later access it programmatically to retrieve a GeoJSON equivalent of it:
965
966
 
966
967
  ```ts
967
968
  // in an async function, or as a 'thenable':
@@ -976,9 +977,9 @@ Read more about fetching your own data on our [official documentation](https://d
976
977
  > ✅ Please, use static maps URLs only from client side `<img>` elements, and do not đŸšĢ store or redistribute the static map files. In case of doubt, consult the [terms](https://www.maptiler.com/cloud/terms/#explicitly-prohibited-use) âš–ī¸
977
978
 
978
979
  Maptiler Cloud provides many possibilities for creating static maps as PNG, JPEG or WebP images. They all offer the possibilities to:
979
- - Choose from one of the MapTiler style or your own
980
- - Add markers with a custom icon (or default icon with custom color)
981
- - Add path or polygon, with a parametric line width and color and a parametric filling color
980
+ - Choose from one of the MapTiler styles or your own
981
+ - Add markers with a custom icon (or default icon with a custom color)
982
+ - Add a path or polygon, with a parametric line width and color and a parametric filling color
982
983
 
983
984
  Three modes are available: `centered`, `bounded` and `automatic`.
984
985
 
@@ -1003,7 +1004,7 @@ In the following static map functions, the `option` object features a `style` pr
1003
1004
  - `MapStyle.BASIC` reference style for minimalist design and general purpose
1004
1005
  - `MapStyle.BASIC.DARK` (variant)
1005
1006
  - `MapStyle.BASIC.LIGHT` (variant)
1006
- - `MapStyle.BRIGHT` reference style for high contrast navigation
1007
+ - `MapStyle.BRIGHT` reference style for high-contrast navigation
1007
1008
  - `MapStyle.BRIGHT.DARK` (variant)
1008
1009
  - `MapStyle.BRIGHT.LIGHT` (variant)
1009
1010
  - `MapStyle.BRIGHT.PASTEL` (variant)
@@ -1096,7 +1097,7 @@ As you may notice, the geo bounding box could have very different proportions th
1096
1097
  Read more about bounded static maps on our official [API documentation](https://docs.maptiler.com/cloud/api/static-maps/#bounds-based-image).
1097
1098
 
1098
1099
  ### Automatic static maps
1099
- As we have seen with centered and bounded maps, providing all the parameters is nice but can be cumbersome for the simplest use cases. This is why MapTiler Cloud also provides static maps that fits automatically whatever you need to place inside: path or markers.
1100
+ As we have seen with centered and bounded maps, providing all the parameters is nice but can be cumbersome for the simplest use cases. This is why MapTiler Cloud also provides static maps that fit automatically whatever you need to place inside: path or markers.
1100
1101
 
1101
1102
  In the following example, we are going to load a cycling track recorded by one of our team members in Montreal, Canada. The track, originally a GPX file, was pushed to MapTiler Data and is now made available as a GeoJSON:
1102
1103
 
@@ -1139,7 +1140,7 @@ And voila!
1139
1140
  Read more about bounded static maps on our official [API documentation](https://docs.maptiler.com/cloud/api/static-maps/#auto-fitted-image).
1140
1141
 
1141
1142
  ## đŸ”ī¸ Elevation
1142
- With the elevation API, it's possible to get the elevation in metter from any location. It's possible to lookup and compute elevation for a single location, to provide a batch of points, from a GeoJSON LineString or from a GeoJSON MultiLineString!
1143
+ With the elevation API, it's possible to get the elevation in meters from any location. It's possible to lookup and compute elevation for a single location, to provide a batch of points, from a GeoJSON LineString or a GeoJSON MultiLineString!
1143
1144
 
1144
1145
  > â„šī¸ Under the hood, the elevation API is fueled by MapTiler Cloud's **RGB Terrain** raster tileset, which is a composite of many high-resolution DEMs from all over the world, currated and processed by our geodata team! The same dataset is also fueling our SDK's elevation (3D terrain) and the hillshading we use in many of our styles.
1145
1146
 
@@ -1182,7 +1183,7 @@ const elevatedPeaks = await maptilersdk.elevation.batch(peaks);
1182
1183
  Read more about elevation lookup for a batch of locations in our [official documentation](https://docs.maptiler.com/client-js/elevation/#batch).
1183
1184
 
1184
1185
  ### From a GeoJSON LineString
1185
- In the *GeoJSON* LineString case, it clones the entire structure and the positions arrays of the clone will contain three element: `[lng, lat, elevation]`. The original LineString is not mutated nor pointed at.
1186
+ In the *GeoJSON* LineString case, it clones the entire structure and the position arrays of the clone will contain three elements: `[lng, lat, elevation]`. The original LineString is not mutated nor pointed at.
1186
1187
 
1187
1188
  ```ts
1188
1189
  // Not mandatory, but it's to explain where the type comes from:
@@ -1201,7 +1202,7 @@ const someElevatedLineString = await maptilersdk.elevation.fromLineString(someLi
1201
1202
  Read more about elevation lookup for a `LineString` in our [official documentation](https://docs.maptiler.com/client-js/elevation/#linestring).
1202
1203
 
1203
1204
  ### From a GeoJSON MultiLineString
1204
- In the *GeoJSON* MultiLineString case, it clones the entire structure and the positions arrays of the clone will contain three element: `[lng, lat, elevation]`. The original MultiLineString is not mutated nor pointed at.
1205
+ In the *GeoJSON* MultiLineString case, it clones the entire structure and the position arrays of the clone will contain three elements: `[lng, lat, elevation]`. The original MultiLineString is not mutated nor pointed at.
1205
1206
 
1206
1207
  ```ts
1207
1208
  // Not mandatory, but it's to explain where the type comes from:
@@ -1227,9 +1228,9 @@ Read more about elevation lookup for a `MultiLineString` in our [official docume
1227
1228
  In order to increase performance while reducing unnecessary elevation data fetching, the elevation tiles are cached. This is particularly important for the LineString and MultiLineString lookups because GeoJSON data are likely to come from a recorded or planned route, where position points are very close to one another.
1228
1229
 
1229
1230
  ## 🧮 Math
1230
- Some operations can be fairly repetitive: WGS84 to Mercator, WGS84 to *zxy* tile index, distance between two points with Haversine formula, etc. As a result, we have decided to expose a `math` package providing the most recurent feature, so that, just like us at MapTiler, you no longer need to copy-paste the same function from your previous project!
1231
+ Some operations can be fairly repetitive: WGS84 to Mercator, WGS84 to *zxy* tile index, the distance between two points with the Haversine formula, etc. As a result, we have decided to expose a `math` package providing the most recurrent feature, so that, just like us at MapTiler, you no longer need to copy-paste the same function from your previous project!
1231
1232
 
1232
- The `math` package differs from the others in the sense that it does not call the MapTiler Cloud API, instead it operates fully on the machine it's running on.
1233
+ The `math` package differs from the others in the sense that it does not call the MapTiler Cloud API, instead, it operates fully on the machine it's running on.
1233
1234
 
1234
1235
  Here are some examples:
1235
1236