Skip to content

Commit 5e42175

Browse files
committed
updates with main branch
2 parents 5b3ed3f + eaf0f7c commit 5e42175

File tree

9 files changed

+374
-47
lines changed

9 files changed

+374
-47
lines changed

.github/workflows/format-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- name: Check out Git repository
10-
uses: actions/checkout@v3
10+
uses: actions/checkout@v4
1111

1212
- name: Set up Node.js
13-
uses: actions/setup-node@v3
13+
uses: actions/setup-node@v4
1414
with:
1515
node-version: 18
1616

.github/workflows/npm-publish.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,28 @@ jobs:
1111
build-and-publish:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v3
15-
- uses: actions/setup-node@v3
14+
- name: Checkout repo
15+
uses: actions/checkout@v4
16+
with:
17+
ref: ${{ github.event.release.target_commitish }}
18+
19+
- uses: actions/setup-node@v4
1620
with:
1721
node-version: 18
1822
registry-url: https://registry.npmjs.org/
1923
- run: npm ci
2024
- run: npm run make
21-
- run: npm publish --access public
25+
26+
- name: Publish NPM package (regular)
27+
if: "!github.event.release.prerelease"
28+
run: |
29+
npm publish
30+
env:
31+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
32+
33+
- name: Publish NPM package (pre-release)
34+
if: "github.event.release.prerelease"
35+
run: |
36+
npm publish --tag next
2237
env:
2338
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88
- Navigation now relies on `Map` methods instead of `Transform` methods for bearing due to globe projection being available
99

1010

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)
1124

1225
## 2.4.0
1326
### New Features
1.94 MB
Loading
2.08 MB
Loading

readme.md

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ maptilersdk.config.apiKey = 'YOUR_API_KEY';
4747
// Let's say you have a DIV ready to receive a map
4848
const mapContainer = document.getElementById('my-container-div');
4949

50-
// Instanciate the map
50+
// Instantiate the map
5151
const map = new maptilersdk.Map({
5252
container: mapContainer,
5353
});
@@ -60,16 +60,16 @@ import * as maptilersdk from '@maptiler/sdk';
6060
// Let's say you have a DIV ready to receive a map
6161
const mapContainer = document.getElementById('my-container-div');
6262

63-
// Instanciate the map
63+
// Instantiate the map
6464
const map = new maptilersdk.Map({
6565
container: mapContainer,
66-
apiKey: 'YOUR_API_KEY';
66+
apiKey: 'YOUR_API_KEY'
6767
});
6868
```
6969

7070
By default, the map will be initialized with the style [streets-v2](https://www.maptiler.com/maps/#style=streets-v2).
7171

72-
Depending on the framework and environment you 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.
7373

7474
For example, with a [NextJS](https://nextjs.org/) app, this can take place at the top of the file `_app.ts/js`:
7575
```ts
@@ -79,7 +79,7 @@ import "@maptiler/sdk/dist/maptiler-sdk.css";
7979
### TypeScript
8080
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.
8181

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.
8383

8484
1. **With `esModuleInterop`**
8585

@@ -237,7 +237,7 @@ All reference styles (instances of `ReferenceMapStyle`) and style variants (inst
237237
___
238238

239239

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:
241241

242242
```ts
243243
map.setStyle('outdoor-v2');
@@ -406,7 +406,7 @@ The `geolocation` options will not be taken into consideration in the following
406406

407407
> 📣 *__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`.
408408
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`.
410410
411411
# Easy to add controls
412412
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:
483483
map.disableTerrain()
484484
```
485485

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.
487487
488488
> 📣 *__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.
489489
@@ -505,7 +505,7 @@ map.on("terrain", (e) => {
505505
})
506506
```
507507

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.
509509

510510
- `"terrainAnimationStart"` and `"terrainAnimationStop"` events
511511

@@ -521,7 +521,7 @@ map.on("terrainAnimationStop", (event) => {
521521
});
522522
```
523523

524-
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`.
525525

526526
In the following example, we decide to associate the terrain animation with a change of camera, e.g. from clicking on the terrain control:
527527
- 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
584584
Here is a sample of some compatible languages:
585585
![](images/screenshots/multilang.gif)
586586

587-
# Built-in support for right-to-left languages
587+
## Built-in support for right-to-left languages
588588
Languages that are written right-to-left such as Arabic and Hebrew are fully supported by default. No need to install any plugins!
589589

590590
<p align="center">
591591
<img src="images/screenshots/lang-arabic.jpeg" width="48%"></img>
592592
<img src="images/screenshots/lang-hebrew.jpeg" width="48%"></img>
593593
</p>
594594

595+
## Visitor language modes
596+
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 = new Map({
602+
// some options...
603+
language: Language.VISITOR,
604+
})
605+
606+
// or
607+
608+
const map = new Map({
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+
![](images/screenshots/visitor_athen.png)
617+
![](images/screenshots/visitor_osaka.png)
618+
619+
595620
# Custom Events and Map Lifecycle
596621
## Events
597622
### The `ready` event
@@ -632,7 +657,7 @@ function init() {
632657
});
633658

634659
// 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.
636661
map.on("load", (evt) => {
637662
// Adding a data source
638663
map.addSource('my-gps-track-source', {
@@ -724,7 +749,7 @@ function init() {
724749
});
725750

726751
// 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.
728753
map.on("ready", (evt) => {
729754
// Adding a data source
730755
map.addSource('my-gps-track-source', {
@@ -762,9 +787,9 @@ We believe that the *promise* approach is better because it does not nest scopes
762787
> 📣 *__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.
763788
764789
### 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.
766791

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.
768793

769794
Here is how to respond to a WebGL context loss with a simple page refresh:
770795
```ts
@@ -855,13 +880,13 @@ maptilersdk.helpers
855880

856881
**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*.
857882

858-
In addition to easy styling, the helper's datasource can be:
883+
In addition to easy styling, the helpers' datasource can be:
859884
- a URL to a geoJSON file or its string content
860885
- a URL to a GPX or KML file (only for the polyline helper) or its string content
861886
- a UUID of a MapTiler Cloud dataset
862887

863888
### 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**.
865890

866891
> 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.
867892
@@ -950,13 +975,12 @@ helpers.addPolyline(map, {
950975

951976
Endless possibilities, what about a glowing wire?
952977
```ts
953-
helpers.addPolyline(map, {
978+
helpers.addPolyline(map, {
954979
data: "74003ba7-215a-4b7e-8e26-5bbe3aa70b05",
955980
lineColor: "#fff",
956981
lineWidth: 1,
957982
outline: true,
958983
outlineColor: "#ca57ff",
959-
outlineWidth: 2,
960984
outlineWidth: 10,
961985
outlineBlur: 10,
962986
outlineOpacity: 0.5,
@@ -968,7 +992,7 @@ helpers.addPolyline(map, {
968992
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).
969993

970994
## 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.
972996

973997
Here is a minimalist example, with a half-transparent polygon of Switzerland, from a local file:
974998

0 commit comments

Comments
 (0)