@maptiler/sdk 1.1.2 → 1.2.1
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/.eslintrc.cjs +15 -5
- package/.github/pull_request_template.md +11 -0
- package/.github/workflows/format-lint.yml +24 -0
- package/CHANGELOG.md +105 -51
- package/colorramp.md +93 -0
- package/dist/maptiler-sdk.d.ts +1226 -124
- package/dist/maptiler-sdk.min.mjs +3 -1
- package/dist/maptiler-sdk.mjs +3582 -483
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/maptiler-sdk.umd.js +4524 -863
- package/dist/maptiler-sdk.umd.js.map +1 -1
- package/dist/maptiler-sdk.umd.min.js +51 -49
- package/package.json +27 -13
- package/readme.md +493 -5
- package/rollup.config.js +2 -16
- package/src/Map.ts +515 -359
- package/src/MaptilerGeolocateControl.ts +23 -20
- package/src/MaptilerLogoControl.ts +3 -3
- package/src/MaptilerNavigationControl.ts +9 -6
- package/src/MaptilerTerrainControl.ts +15 -14
- package/src/Minimap.ts +373 -0
- package/src/Point.ts +3 -5
- package/src/colorramp.ts +1216 -0
- package/src/config.ts +4 -3
- package/src/converters/index.ts +1 -0
- package/src/converters/xml.ts +681 -0
- package/src/defaults.ts +1 -1
- package/src/helpers/index.ts +27 -0
- package/src/helpers/stylehelper.ts +395 -0
- package/src/helpers/vectorlayerhelpers.ts +1511 -0
- package/src/index.ts +90 -121
- package/src/language.ts +116 -79
- package/src/mapstyle.ts +4 -2
- package/src/tools.ts +68 -16
- package/tsconfig.json +8 -5
- package/vite.config.ts +10 -0
- package/demos/maptiler-sdk.css +0 -147
- package/demos/maptiler-sdk.umd.js +0 -4041
- package/demos/mountain.html +0 -67
- package/demos/simple.html +0 -67
- package/demos/transform-request.html +0 -81
package/.eslintrc.cjs
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
+
const tsConfig = require('./tsconfig.json');
|
|
2
|
+
|
|
1
3
|
module.exports = {
|
|
2
|
-
extends: [
|
|
4
|
+
extends: [
|
|
5
|
+
'eslint:recommended',
|
|
6
|
+
'plugin:@typescript-eslint/recommended',
|
|
7
|
+
'prettier'
|
|
8
|
+
],
|
|
3
9
|
parser: '@typescript-eslint/parser',
|
|
4
|
-
plugins: [
|
|
10
|
+
plugins: [
|
|
11
|
+
'@typescript-eslint',
|
|
12
|
+
'prettier'
|
|
13
|
+
],
|
|
5
14
|
root: true,
|
|
6
|
-
//"@typescript-eslint/ban-ts-comment": "warn"
|
|
7
15
|
rules: {
|
|
8
16
|
"@typescript-eslint/ban-ts-comment": "warn",
|
|
9
|
-
|
|
10
|
-
}
|
|
17
|
+
"prettier/prettier": "error",
|
|
18
|
+
},
|
|
19
|
+
ignorePatterns: tsConfig.exclude,
|
|
20
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: Format and Lint
|
|
2
|
+
|
|
3
|
+
on: [pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
format-and-lint:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- name: Check out Git repository
|
|
10
|
+
uses: actions/checkout@v3
|
|
11
|
+
|
|
12
|
+
- name: Set up Node.js
|
|
13
|
+
uses: actions/setup-node@v3
|
|
14
|
+
with:
|
|
15
|
+
node-version: 18
|
|
16
|
+
|
|
17
|
+
- name: Install Node.js dependencies
|
|
18
|
+
run: npm ci
|
|
19
|
+
|
|
20
|
+
- name: Formatting with Prettier
|
|
21
|
+
run: npm run format
|
|
22
|
+
|
|
23
|
+
- name: Linting with ESLint
|
|
24
|
+
run: npm run lint
|
package/CHANGELOG.md
CHANGED
|
@@ -1,37 +1,88 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
##
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
# MapTiler SDK Changelog
|
|
2
|
+
|
|
3
|
+
## DEVEL
|
|
4
|
+
### New Features
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
### Others
|
|
7
|
+
|
|
8
|
+
## 1.2.1
|
|
9
|
+
### New Features
|
|
10
|
+
- Elevation lookup at `maptilersdk.elevation` with the function `.at()`, `.batch()` and for geojson payloads. From the update of the MapTiler Client library
|
|
11
|
+
- the new `ready` event. Called only once after `load` and wait for all the controls managed by the Map constructor to be dealt with (as one relies on async logic)
|
|
12
|
+
- the new Map lifecycle method `.onReadyAsync()` corresponding to a promise-based equivalent of the the `ready` event.
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
- The index now exposes the geocoding option types from the Client library
|
|
15
|
+
### Others
|
|
16
|
+
- Update of the Maptiler Client library to v1.8.0 that brings the elevation and math module
|
|
17
|
+
- Update with the last version of MapLibre GL JS (v3.6.2)
|
|
18
|
+
|
|
19
|
+
## 1.2.0
|
|
20
|
+
### New Features
|
|
21
|
+
- Added the Minimap control https://github.com/maptiler/maptiler-sdk-js/pull/54
|
|
22
|
+
- Added vector layer helpers to create easier:
|
|
23
|
+
- point layer (https://github.com/maptiler/maptiler-sdk-js/pull/61)
|
|
24
|
+
- heatmap layer (https://github.com/maptiler/maptiler-sdk-js/pull/61)
|
|
25
|
+
- polyline layer, including parsing from GPX/KML (https://github.com/maptiler/maptiler-sdk-js/pull/51)
|
|
26
|
+
- polygon layer (https://github.com/maptiler/maptiler-sdk-js/pull/56)
|
|
27
|
+
- Add the `ColorRamp` class to create and customize color ramps, as well as `ColorRampCollection` with many predefined ones (as part of https://github.com/maptiler/maptiler-sdk-js/pull/61)
|
|
28
|
+
- Improved the language management for increased compatibility with [MapTiler Customize](https://cloud.maptiler.com/maps/editor/) (https://github.com/maptiler/maptiler-sdk-js/pull/58)
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
- Fixed type export (https://github.com/maptiler/maptiler-sdk-js/pull/47)
|
|
31
|
+
### Others
|
|
32
|
+
- Upgrade to MapLibre v3.5.2 (https://github.com/maptiler/maptiler-sdk-js/pull/63)
|
|
33
|
+
- Update of TypeScript configuration `moduleResolution` to `Bundler` (https://github.com/maptiler/maptiler-sdk-js/pull/62)
|
|
34
|
+
|
|
35
|
+
## 1.1.2
|
|
36
|
+
### Bug Fixes
|
|
37
|
+
- Now using a fixed version of MapLibre GL. No longer use `^` because this caused issues as MapLibre made minor/patch update that were not backward compatible
|
|
38
|
+
|
|
39
|
+
## 1.1.1
|
|
40
|
+
### Others
|
|
41
|
+
- Update to `maplibre-gl@3.1.0`
|
|
42
|
+
|
|
43
|
+
## 1.1.0
|
|
44
|
+
### New Features
|
|
45
|
+
- Bringing back Map's `options.transformRequest` and `.setTransformRequest()`
|
|
46
|
+
### Bug Fixes
|
|
47
|
+
- Fixed the MapTiler logo rel name and its nofollow feature
|
|
48
|
+
- Made the few necessary changes acording to updating the ML v3. No braking change for SDK API
|
|
49
|
+
### Others
|
|
50
|
+
- Updated from `maplibre-gl@3.0.0-pre.4` to `maplibre-gl@3.0.1` (this includes the switch to WebGL2)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## 1.0.12
|
|
54
|
+
### New Features
|
|
55
|
+
- Added a new language flag `Language.STYLE_LOCK` to force keep the language form the style and prevent any further update. Can be at a sigle map instance level (via constuctor option `language`) or via global config (`config.primaryLanguage`)
|
|
56
|
+
### Bug Fixes
|
|
57
|
+
- The fallback language was `{name:latin}`, it is now replaced by `{name}`, which is for the local name (present by default for many places while `latin` is less frequent).
|
|
58
|
+
|
|
59
|
+
## 1.0.11
|
|
60
|
+
### Bug Fixes
|
|
61
|
+
- Now exporting `MaptilerNavigationControl`
|
|
62
|
+
### Others
|
|
63
|
+
- Documentation update for `Map`'s `option.maptilerLogo` that was a bit unclear
|
|
64
|
+
|
|
65
|
+
## 1.0.10
|
|
66
|
+
### New Features
|
|
67
|
+
- Terrain growing animation on enabling/disabling
|
|
68
|
+
- Added `Map` custom event `loadWithTerrain`
|
|
69
|
+
- Added `Map` lifecycle methods `.onLoadAsync()` and `.onLoadWithTerrainAsync()`
|
|
70
|
+
### Others
|
|
71
|
+
- Readme section was added about the event an methods above
|
|
72
|
+
- Updated from `maplibre-gl@3.0.0-pre.3` to `maplibre-gl@3.0.0-pre.4`
|
|
73
|
+
- Updated from `typedoc@0.23.21` to `typedoc@0.24.4`, which changes slightly the look of the reference documentation.
|
|
74
|
+
- Updated from `typescript@4.8.4` to `typescript@5.0.4`
|
|
75
|
+
- Updated from `rollup@2.79.0` to `rollup@3.20.6` as well as all the Rollup plugins
|
|
76
|
+
|
|
77
|
+
## 1.0.9
|
|
78
|
+
### New Features
|
|
79
|
+
- Added new styles:
|
|
80
|
+
- `MapStyle.STREETS.NIGHT`
|
|
81
|
+
- `MapStyle.WINTER.DARK`
|
|
82
|
+
- `MapStyle.OUTDOOR.DARK`
|
|
83
|
+
### Bug Fixes
|
|
84
|
+
- If the geolocate option is missing from `Map` constructor, then it's considered `false`
|
|
85
|
+
- The instance types for the following MapLibre classes are now fully exported:
|
|
35
86
|
- `NavigationControl`
|
|
36
87
|
- `GeolocateControl`
|
|
37
88
|
- `AttributionControl`
|
|
@@ -55,8 +106,7 @@
|
|
|
55
106
|
- `VectorTileSource`
|
|
56
107
|
- `VideoSource`
|
|
57
108
|
- `MapMLGL`
|
|
58
|
-
|
|
59
|
-
- FIX: The following class have been extended to provide greater compatibility with SDK,s MapL
|
|
109
|
+
- The following class have been extended to provide greater compatibility with SDK,s MapL
|
|
60
110
|
- `Popup`
|
|
61
111
|
- `Marker`
|
|
62
112
|
- `Style`
|
|
@@ -75,40 +125,44 @@
|
|
|
75
125
|
- `FullscreenControl`
|
|
76
126
|
- `TerrainControl`
|
|
77
127
|
|
|
78
|
-
- ADD: new styles:
|
|
79
|
-
- `MapStyle.STREETS.NIGHT`
|
|
80
|
-
- `MapStyle.WINTER.DARK`
|
|
81
|
-
- `MapStyle.OUTDOOR.DARK`
|
|
82
128
|
|
|
83
|
-
##
|
|
84
|
-
|
|
129
|
+
## 1.0.8
|
|
130
|
+
### Bug Fixes
|
|
131
|
+
- Since v1.0.7, the `Map` primary language (when custom) was no longer persistant on style update.
|
|
85
132
|
|
|
86
|
-
##
|
|
133
|
+
## 1.0.7
|
|
134
|
+
### New Features
|
|
87
135
|
- The `apiKey` can now be specified in the `Map` constructor (will propagate to `config`)
|
|
88
136
|
- The `language` can now be speficifed in the `Map` constructo (will **not** propagete to `config` and will apply only to this specific instance)
|
|
89
137
|
- `Map` now has the method `.getSdkConfig()` to retrieve the config object.
|
|
90
138
|
- `Map` now has the method `.getMaptilerSessionId()` to retrieve the MapTiler session ID
|
|
91
|
-
|
|
92
139
|
Both `.getSdkConfig()` and `.getMaptilerSessionId()` are handy for layers or control built outside of the SDK that still need some of the configuration to interact with the server. Those components do not always have access to the internal of the SDK (especially that the config is scoped) but can access to the `Map` instance to which they are added with the implementation of the `.onAdd()` method.
|
|
93
140
|
|
|
94
|
-
##
|
|
141
|
+
## 1.0.6
|
|
142
|
+
### New Features
|
|
95
143
|
- Now exposing `MaptilerGeolocateControl` for external initialization if needed
|
|
96
144
|
- Now exposing `MaptilerTerrain` for external initialization if needed
|
|
97
145
|
|
|
98
|
-
##
|
|
146
|
+
## 1.0.5
|
|
147
|
+
### New Features
|
|
99
148
|
- Terrain elevation is now using MapTiler's `terrain-rgb-v2`
|
|
100
149
|
|
|
101
|
-
##
|
|
150
|
+
## 1.0.4
|
|
151
|
+
### Others
|
|
102
152
|
- Improved the geolocate control behavior by not zooming out
|
|
103
153
|
|
|
104
|
-
##
|
|
154
|
+
## 1.0.3
|
|
155
|
+
### Bug Fixes
|
|
105
156
|
- Fixed the usage of relative path style JSON (in `Map` constructor and `.setStyle()`)
|
|
106
157
|
|
|
107
|
-
##
|
|
158
|
+
## 1.0.2
|
|
159
|
+
### Bug Fixes
|
|
108
160
|
- Fixed the dependency scheme of MapLibre import.
|
|
109
161
|
|
|
110
|
-
##
|
|
162
|
+
## 1.0.1
|
|
163
|
+
### Others
|
|
111
164
|
- Reducing the NPM size by ignoring documentation images
|
|
112
165
|
|
|
113
|
-
##
|
|
166
|
+
## 1.0.0
|
|
167
|
+
### Others
|
|
114
168
|
- First public version!
|
package/colorramp.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# ColorRamps resampling
|
|
2
|
+
`ColorRamps` in the SDK, whether they are built-in (`ColorRampCollection`) or custom made (`new ColorRamp()`) can be resampled in a non linear fashion. Such resampling can serve different purposes, for instance:
|
|
3
|
+
- the data to visualize follows a non-linear function
|
|
4
|
+
- the goal of the visualization is to specificaly emphasize difference towards the lower or upper bound of the range
|
|
5
|
+
|
|
6
|
+
Creating a non linear color ramp can be a bit difficult, so resampling an existing one that has been originaly created as linear is easier. At the moment, the SDK provides four methods to resample a color ramp with the `.resample()` function:
|
|
7
|
+
- folowing a square function: `"ease-in-square"`
|
|
8
|
+
- folowing a square function: `"ease-out-square"`
|
|
9
|
+
- following a square root: `"ease-in-sqrt"`
|
|
10
|
+
- following a square root: `"ease-out-sqrt"`
|
|
11
|
+
- folowing an exponential function: `"ease-in-exp"`
|
|
12
|
+
- folowing an exponential function: `"ease-in-exp"`
|
|
13
|
+
|
|
14
|
+
Note: the *ease-out* equivalent of *ease-in-square* is technically *ease-out-square* and the *ease-in* equivalent of *ease-out-sqrt* is technically *ease-in-sqrt* but after some tests, it appeared that `"ease-in-square"` and `"ease-out-sqrt"` where a better pairing so this is why we decided to focus mainly on those two.
|
|
15
|
+
|
|
16
|
+
Terminology:
|
|
17
|
+
- an function is said **ease in** when its acceleration is fairly low at the begining and much higher towards the end
|
|
18
|
+
- an function is said **ease out** when its acceleration is quite high at begining and much lower towards the end
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Linear logic
|
|
22
|
+
All the built-in color ramps are defined in a range of `(0, 1)`. Even though they can be scaled (`.scale(min, max)`) or custom ones can be created on a diferent interval, the range of (0, 1) is the most convenient to visualize how things work. Also, to keep it simple we are using a linear gray color ramp going from `(R:0, G:0, B:0)` to `(R:255, G:255, B:255)`. You can find this specific one as `ColorRampCollection.GRAY`.
|
|
23
|
+
|
|
24
|
+

|
|
25
|
+
|
|
26
|
+
- along the `x` axis (horizontal), the input number. This can be the intensity or any real-worl metric
|
|
27
|
+
- along the `y` axis (vertical), the output color
|
|
28
|
+
|
|
29
|
+
As we can see:
|
|
30
|
+
- an input of `0` will yied the color `(R:0, G:0, B:0)`
|
|
31
|
+
- an input of `0.5` will yied the color `(R:127, G:127, B:127)`
|
|
32
|
+
- an input of `1` will yied the color `(R:255, G:255, B:255)`
|
|
33
|
+
|
|
34
|
+
The original linear GRAY color ramp looks like this:
|
|
35
|
+
|
|
36
|
+

|
|
37
|
+
|
|
38
|
+
## *ease-out-sqrt* method
|
|
39
|
+
To resample a color ramp with the *square root* method, simply do:
|
|
40
|
+
```ts
|
|
41
|
+
const graySqrt = ColorRampCollection.GRAY.resample("ease-out-sqrt");
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Note: this will **not** modify the origin `ColorRampCollection.GRAY`.
|
|
45
|
+
|
|
46
|
+
There are multiple ways to visualize the effect of such resampling. The simplest is probably to do as above (*linear logic*), but using a *square root* function:
|
|
47
|
+
|
|
48
|
+

|
|
49
|
+
|
|
50
|
+
This will yield the following color ramp:
|
|
51
|
+
|
|
52
|
+

|
|
53
|
+
|
|
54
|
+
If we compare with the linear GRAY from above, we can see that the lower part (the darkest) is sort of compressed, while the upper part (the lightest) looks stretched.
|
|
55
|
+
|
|
56
|
+
As a result:
|
|
57
|
+
- an input of `0` will yied the color `(R:0, G:0, B:0)`
|
|
58
|
+
- an input of `0.5` will yied the color `(R:180, G:180, B:180)`
|
|
59
|
+
- an input of `1` will yied the color `(R:255, G:255, B:255)`
|
|
60
|
+
|
|
61
|
+
Another way to look at the *ease-out-sqrt-resampled* GRAY color ramp is by using it along the `y` axis and addressing it with data that are following a linear rule:
|
|
62
|
+

|
|
63
|
+
|
|
64
|
+
This can be convenient to do if the purpose is to emphasize the change of values on the lower-end, say in the range `(0, 0.4)` as the color response will be faster-changing than with a linear scale.
|
|
65
|
+
|
|
66
|
+
## *ease-in-square* method
|
|
67
|
+
To resample a color ramp with the *square* method, simply do:
|
|
68
|
+
```ts
|
|
69
|
+
const graySquare = ColorRampCollection.GRAY.resample("ease-in-square");
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Note: this will **not** modify the origin `ColorRampCollection.GRAY`.
|
|
73
|
+
|
|
74
|
+
Let's visualize it, using the original linear gradient along the `y` axis:
|
|
75
|
+
|
|
76
|
+

|
|
77
|
+
|
|
78
|
+
This will yield the following color ramp:
|
|
79
|
+
|
|
80
|
+

|
|
81
|
+
|
|
82
|
+
As we can see, compared to the linear ramping, the change is color is slower towards the lower end and faster towards the end of the range.
|
|
83
|
+
|
|
84
|
+
As a result:
|
|
85
|
+
- an input of `0` will yied the color `(R:0, G:0, B:0)`
|
|
86
|
+
- an input of `0.5` will yied the color `(R:64, G:64, B:64)`
|
|
87
|
+
- an input of `1` will yied the color `(R:255, G:255, B:255)`
|
|
88
|
+
|
|
89
|
+
Again, we can visualize a *ease-in-square-resampled* color ramp by using it alongside the `y` axis, with linear data:
|
|
90
|
+
|
|
91
|
+

|
|
92
|
+
|
|
93
|
+
Contrary to the *ease-out-sqrt* method, the *ease-in-square* will yield faster changing colors on the upper bound of the input range.
|