You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+13Lines changed: 13 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,19 @@
8
8
- Navigation now relies on `Map` methods instead of `Transform` methods for bearing due to globe projection being available
9
9
10
10
11
+
## 2.4.2
12
+
### Bug Fixes
13
+
- The language switching is now more robust and preserves the original formatting from the style (`Map.setPrimaryLangage()`) (https://github.com/maptiler/maptiler-sdk-js/pull/134)
14
+
15
+
### Others
16
+
- Now able to GitHub action a beta on NPM from the GH release creation process
17
+
- Updated GH action to v4
18
+
19
+
20
+
## 2.4.1
21
+
### Bug Fixes
22
+
- The class `AJAXError` is now imported as part of the `maplibregl` namespace (CommonJS limitation from Maplibre GL JS) (https://github.com/maptiler/maptiler-sdk-js/pull/129)
23
+
- The `Map` constructor can now also take a language as a string (https://github.com/maptiler/maptiler-sdk-js/pull/131)
The SDK is fully typed, but it may happen that types defined in Maplibre GL JS are not visible in your project. This is a known issue that comes from Maplibre being a CommonJS bundle.
81
81
82
-
There are mainly two ways to addess this issue and access to the complete type definition.
82
+
There are mainly two ways to address this issue and access to the complete type definition.
83
83
84
84
1.**With `esModuleInterop`**
85
85
@@ -237,7 +237,7 @@ All reference styles (instances of `ReferenceMapStyle`) and style variants (inst
237
237
___
238
238
239
239
240
-
Still, you can still use some classic styles with just a *string* if you know their MapTiler Cloud ID:
240
+
You can also use classic styles with just a *string* if you know their MapTiler Cloud ID:
241
241
242
242
```ts
243
243
map.setStyle('outdoor-v2');
@@ -406,7 +406,7 @@ The `geolocation` options will not be taken into consideration in the following
406
406
407
407
> 📣 *__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`.
408
408
409
-
> 📣 *__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`.
409
+
> 📣 *__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 generally better not to use a zoom level higher than `14`.
410
410
411
411
# Easy to add controls
412
412
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:
@@ -483,7 +483,7 @@ Or simply disable it:
483
483
map.disableTerrain()
484
484
```
485
485
486
-
> 📣 *__Note:__* Keep in mind that setting an exaggeration factor at `0` will result in a the same result as disabling the elevation but that terrain RGB tiles will still be fetched in the background.
486
+
> 📣 *__Note:__* Keep in mind that setting an exaggeration factor at `0` will result in the same result as disabling the elevation but that terrain RGB tiles will still be fetched in the background.
487
487
488
488
> 📣 *__Note 2:__* please be aware that due to the volume and elevation of the map floor in 3D space, the navigation with the terrain enabled is slightly different than without.
489
489
@@ -505,7 +505,7 @@ map.on("terrain", (e) => {
505
505
})
506
506
```
507
507
508
-
Since MapTiler SDK adds animation and the terrain data is necessary all along, the `"terrain"` event will be called at the very begining of the terrain animation when enabling and at the very end when disabling.
508
+
Since MapTiler SDK adds animation and the terrain data is necessary all along, the `"terrain"` event will be called at the very beginning of the terrain animation when enabling and at the very end when disabling.
509
509
510
510
-`"terrainAnimationStart"` and `"terrainAnimationStop"` events
The `event` argument is an object that contains (amond other things) a `terrain` attribute. In the case of `"terrainAnimationStop"`, this terrain attribute is `null` if the animation was about disabling the terrain, otherwise, this is just a propagation of `map.terrain`.
524
+
The `event` argument is an object that contains (among other things) a `terrain` attribute. In the case of `"terrainAnimationStop"`, this terrain attribute is `null` if the animation was about disabling the terrain, otherwise, this is just a propagation of `map.terrain`.
525
525
526
526
In the following example, we decide to associate the terrain animation with a change of camera, e.g. from clicking on the terrain control:
527
527
- when the terrain is enabled, it pops up with an animation and only **then** the camera is animated to take a lower point of view
@@ -584,14 +584,39 @@ Whenever a label is not supported in the defined language, it falls back to `Lan
584
584
Here is a sample of some compatible languages:
585
585

586
586
587
-
# Built-in support for right-to-left languages
587
+
##Built-in support for right-to-left languages
588
588
Languages that are written right-to-left such as Arabic and Hebrew are fully supported by default. No need to install any plugins!
The *visitor* language modes are special built-in modes made to display labels in two different languages, concatenated when available:
597
+
-`Language.VISITOR` concatenates labels in the language of your system and the *local* language
598
+
-`Language.VISITOR_ENGLISH` concatenates labels in English and the *local* language
599
+
600
+
```ts
601
+
const map =newMap({
602
+
// some options...
603
+
language: Language.VISITOR,
604
+
})
605
+
606
+
// or
607
+
608
+
const map =newMap({
609
+
// some options...
610
+
language: Language.VISITOR_ENGLISH,
611
+
})
612
+
```
613
+
614
+
We believe these two modes can be very handy to help the end users identify places, especially when the local labels are not using a latin charset. Here is how it looks like:
615
+
616
+

617
+

618
+
619
+
595
620
# Custom Events and Map Lifecycle
596
621
## Events
597
622
### The `ready` event
@@ -632,7 +657,7 @@ function init() {
632
657
});
633
658
634
659
// We wait for the event.
635
-
// Once triggered, the callback is ranin it's own scope.
660
+
// Once triggered, the callback is ran in its own scope.
636
661
map.on("load", (evt) => {
637
662
// Adding a data source
638
663
map.addSource('my-gps-track-source', {
@@ -724,7 +749,7 @@ function init() {
724
749
});
725
750
726
751
// We wait for the event.
727
-
// Once triggered, the callback is ranin it's own scope.
752
+
// Once triggered, the callback is ran in its own scope.
728
753
map.on("ready", (evt) => {
729
754
// Adding a data source
730
755
map.addSource('my-gps-track-source', {
@@ -762,9 +787,9 @@ We believe that the *promise* approach is better because it does not nest scopes
762
787
> 📣 *__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.
763
788
764
789
### The `webglContextLost` event
765
-
The maps is rendered with WebGL, that leverages the GPU to provide high-performance graphics. In some cases, the host machine, operating system or the graphics driver, can decide that continuing to run such high performance graphics is unsustainable, and will abort the process. This is called a "WebGL context loss". Such situation happens when the ressources are running low or when multiple browser tabs are competing to access graphics memory.
790
+
The map is rendered with WebGL, that leverages the GPU to provide high-performance graphics. In some cases, the host machine, operating system or the graphics driver, can decide that continuing to run such high performance graphics is unsustainable, and will abort the process. This is called a "WebGL context loss". Such situation happens when the resources are running low or when multiple browser tabs are competing to access graphics memory.
766
791
767
-
The best course of action in such situation varies from an app to another. Sometimes a page refresh is the best thing to do, in other cases, instantiating a new Map dynmicaly at application level is more appropriate because it hides a technical failure to the end user. The event `webglContextLost` is exposed so that the most appropriate scenario can be implemented at application level.
792
+
The best course of action in such situation varies from an app to another. Sometimes a page refresh is the best thing to do, in other cases, instantiating a new Map dynamically at application level is more appropriate because it hides a technical failure to the end user. The event `webglContextLost` is exposed so that the most appropriate scenario can be implemented at application level.
768
793
769
794
Here is how to respond to a WebGL context loss with a simple page refresh:
770
795
```ts
@@ -855,13 +880,13 @@ maptilersdk.helpers
855
880
856
881
**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*.
857
882
858
-
In addition to easy styling, the helper's datasource can be:
883
+
In addition to easy styling, the helpers' datasource can be:
859
884
- a URL to a geoJSON file or its string content
860
885
- a URL to a GPX or KML file (only for the polyline helper) or its string content
861
886
- a UUID of a MapTiler Cloud dataset
862
887
863
888
### Multiple Layers
864
-
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**.
889
+
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**.
865
890
866
891
> 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.
867
892
@@ -950,13 +975,12 @@ helpers.addPolyline(map, {
950
975
951
976
Endless possibilities, what about a glowing wire?
952
977
```ts
953
-
helpers.addPolyline(map, {
978
+
helpers.addPolyline(map, {
954
979
data: "74003ba7-215a-4b7e-8e26-5bbe3aa70b05",
955
980
lineColor: "#fff",
956
981
lineWidth: 1,
957
982
outline: true,
958
983
outlineColor: "#ca57ff",
959
-
outlineWidth: 2,
960
984
outlineWidth: 10,
961
985
outlineBlur: 10,
962
986
outlineOpacity: 0.5,
@@ -968,7 +992,7 @@ helpers.addPolyline(map, {
968
992
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).
969
993
970
994
## Polygon Layer Helper
971
-
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.
995
+
The polygon helper makes it easy to create vector layers that contain polygons, whether they are *multi*polygons, *holed*polygons or just simple polygons. Whenever it's possible and it makes sense, we use the same terminology across the different helpers.
972
996
973
997
Here is a minimalist example, with a half-transparent polygon of Switzerland, from a local file:
0 commit comments