@maptiler/sdk 1.2.0 → 2.0.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.
Files changed (63) hide show
  1. package/.eslintrc.cjs +1 -0
  2. package/dist/maptiler-sdk.css +1 -1
  3. package/dist/maptiler-sdk.d.ts +190 -241
  4. package/dist/maptiler-sdk.min.mjs +3 -3
  5. package/dist/maptiler-sdk.mjs +487 -460
  6. package/dist/maptiler-sdk.mjs.map +1 -1
  7. package/package.json +3 -3
  8. package/readme.md +211 -6
  9. package/CHANGELOG.md +0 -157
  10. package/colorramp.md +0 -93
  11. package/dist/maptiler-sdk.umd.js +0 -6997
  12. package/dist/maptiler-sdk.umd.js.map +0 -1
  13. package/dist/maptiler-sdk.umd.min.js +0 -582
  14. package/src/AttributionControl.ts +0 -13
  15. package/src/CanvasSource.ts +0 -13
  16. package/src/FullscreenControl.ts +0 -13
  17. package/src/GeoJSONSource.ts +0 -13
  18. package/src/GeolocateControl.ts +0 -13
  19. package/src/ImageSource.ts +0 -13
  20. package/src/LogoControl.ts +0 -13
  21. package/src/Map.ts +0 -1328
  22. package/src/MaptilerGeolocateControl.ts +0 -207
  23. package/src/MaptilerLogoControl.ts +0 -58
  24. package/src/MaptilerNavigationControl.ts +0 -69
  25. package/src/MaptilerTerrainControl.ts +0 -72
  26. package/src/Marker.ts +0 -13
  27. package/src/Minimap.ts +0 -373
  28. package/src/NavigationControl.ts +0 -13
  29. package/src/Point.ts +0 -334
  30. package/src/Popup.ts +0 -13
  31. package/src/RasterDEMTileSource.ts +0 -13
  32. package/src/RasterTileSource.ts +0 -13
  33. package/src/ScaleControl.ts +0 -13
  34. package/src/Style.ts +0 -13
  35. package/src/TerrainControl.ts +0 -13
  36. package/src/VectorTileSource.ts +0 -13
  37. package/src/VideoSource.ts +0 -13
  38. package/src/colorramp.ts +0 -1216
  39. package/src/config.ts +0 -96
  40. package/src/converters/index.ts +0 -1
  41. package/src/converters/xml.ts +0 -681
  42. package/src/defaults.ts +0 -20
  43. package/src/helpers/index.ts +0 -27
  44. package/src/helpers/stylehelper.ts +0 -395
  45. package/src/helpers/vectorlayerhelpers.ts +0 -1511
  46. package/src/index.ts +0 -242
  47. package/src/language.ts +0 -183
  48. package/src/mapstyle.ts +0 -46
  49. package/src/style/style_template.css +0 -146
  50. package/src/style/svg/v6-compass.svg +0 -12
  51. package/src/style/svg/v6-fullscreen-off.svg +0 -7
  52. package/src/style/svg/v6-fullscreen.svg +0 -7
  53. package/src/style/svg/v6-geolocate-active-error.svg +0 -10
  54. package/src/style/svg/v6-geolocate-active.svg +0 -7
  55. package/src/style/svg/v6-geolocate-background.svg +0 -8
  56. package/src/style/svg/v6-geolocate-disabled.svg +0 -10
  57. package/src/style/svg/v6-geolocate.svg +0 -7
  58. package/src/style/svg/v6-terrain-on.svg +0 -7
  59. package/src/style/svg/v6-terrain.svg +0 -7
  60. package/src/style/svg/v6-zoom-minus.svg +0 -7
  61. package/src/style/svg/v6-zoom-plus.svg +0 -7
  62. package/src/tools.ts +0 -171
  63. package/src/unit.ts +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maptiler/sdk",
3
- "version": "1.2.0",
3
+ "version": "2.0.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",
@@ -74,10 +74,10 @@
74
74
  "xmldom": "^0.6.0"
75
75
  },
76
76
  "dependencies": {
77
- "@maptiler/client": "^1.7.0",
77
+ "@maptiler/client": "^1.8.1",
78
78
  "events": "^3.3.0",
79
79
  "js-base64": "^3.7.4",
80
- "maplibre-gl": "3.5.2",
80
+ "maplibre-gl": "4.1.2",
81
81
  "uuid": "^9.0.0"
82
82
  }
83
83
  }
package/readme.md CHANGED
@@ -22,6 +22,8 @@ The **MapTiler SDK JS** extends MapLibre GL JS, exposes all its features, and ad
22
22
  In addition, the MapTiler SDK JS provides well-documented and easy-to-use wrapper functions to the [MapTiler Cloud API services](https://docs.maptiler.com/cloud/api) such as: geocoding, static maps, geolocation, as well as a search engine for coordinate reference systems and transforming coordinates from one CRS to another.
23
23
  > 📣 *__Note:__* If you need <ins>only the API Client library</ins> to use in a headless fashion and without any map display, check out [MapTiler Client JS](https://github.com/maptiler/maptiler-client-js) library for browser and NodeJS.
24
24
 
25
+ ![Lake Louise, Canada, with MapTiler Outdoor style](images/screenshots/lake-louise.jpg)
26
+
25
27
  # Install
26
28
  ```shell
27
29
  npm install --save @maptiler/sdk
@@ -51,7 +53,7 @@ const map = new maptilersdk.Map({
51
53
  });
52
54
  ```
53
55
 
54
- Alternativelly, the `apiKey` can be set as Map option intead of in the `config` object. Yet, this will still internally propagate to the `config` obejct:
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:
55
57
  ```ts
56
58
  import * as maptilersdk from '@maptiler/sdk';
57
59
 
@@ -172,6 +174,9 @@ Here is the full list:
172
174
  - `MapStyle.DATAVIZ`, the perfect style for data visualization, with very little noise
173
175
  - `MapStyle.DATAVIZ.DARK` (variant)
174
176
  - `MapStyle.DATAVIZ.LIGHT` (variant)
177
+ - `MapStyle.BACKDROP`, great style for data visualization when hillshading matters!
178
+ - `MapStyle.BACKDROP.DARK` (variant)
179
+ - `MapStyle.BACKDROP.LIGHT` (variant)
175
180
  - `MapStyle.BASIC` reference style for minimalist design and general purpose
176
181
  - `MapStyle.BASIC.DARK` (variant)
177
182
  - `MapStyle.BASIC.LIGHT` (variant)
@@ -392,16 +397,32 @@ Languages that are written right-to-left such as arabic and hebrew are fully sup
392
397
 
393
398
  # Custom Events and Map Lifecycle
394
399
  ## Events
395
- Since the SDK is fully compatible with MapLibre, [all these events](https://maplibre.org/maplibre-gl-js-docs/api/map/#map-events) are available, yet we have added one more: `loadWithTerrain`.
400
+ ### 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.
396
403
 
397
- The `loadWithTerrain` event is triggered only *once* in a `Map` instance lifecycle, when both the `load` event and the `terrain` event **with non-null terrain** are fired.
404
+ This event works exactely the same way as `load` and you can safely replace those by `"ready"`. Here is a usage example:
405
+
406
+ ```js
407
+ const map = new maptilersdk.Map({
408
+ container: "map-container",
409
+ });
410
+
411
+ map.on("ready", (evt) => {
412
+ const terrainControl = new maptilersdk.MaptilerTerrainControl();
413
+ map.addControl(terrainControl);
414
+ })
415
+ ```
416
+
417
+ ### The `loadWithTerrain` event
418
+ 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.
398
419
 
399
420
  **Why a new event?**
400
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.
401
- Relying on the `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.
422
+ 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.
402
423
 
403
424
  ## Lifecycle Methods
404
- The events `load` and `loadWithTerrain` are both called *at most once* and require a callback function to add more elements such as markers, layers, popups and data sources. Even though MapTiler SDK fully supports this logic, we have also included a *promise* logic to provide a more linear and less nested way to wait for a Map instance to be ready. Let's compare the two ways:
425
+ The events `load`, `ready` and `loadWithTerrain` are both called *at most once* and require a callback function to add more elements such as markers, layers, popups and data sources. Even though MapTiler SDK fully supports this logic, we have also included a *promise* logic to provide a more linear and less nested way to wait for a Map instance to be usable. Let's compare the two ways:
405
426
 
406
427
  - Classic: with a callback on the `load` event:
407
428
  ```ts
@@ -494,9 +515,54 @@ async function init() {
494
515
  }
495
516
  ```
496
517
 
518
+ And finally, the lifecycle method corresponding to the `ready` event:
519
+ - Classic: with a callback on the `ready` event:
520
+ ```ts
521
+ function init() {
522
+
523
+ const map = new Map({
524
+ container,
525
+ center: [2.34804, 48.85439], // Paris, France
526
+ zoom: 14,
527
+ });
528
+
529
+ // We wait for the event.
530
+ // Once triggered, the callback is ranin it's own scope.
531
+ map.on("ready", (evt) => {
532
+ // Adding a data source
533
+ map.addSource('my-gps-track-source', {
534
+ type: "geojson",
535
+ data: "https://example.com/some-gps-track.geojson",
536
+ });
537
+ })
538
+ }
539
+ ```
540
+
541
+ - Modern: with a promise returned by the method `.onReadyAsync()`, used in an `async` function:
542
+ ```ts
543
+ async function init() {
544
+
545
+ const map = new Map({
546
+ container,
547
+ center: [2.34804, 48.85439], // Paris, France
548
+ zoom: 14,
549
+ });
550
+
551
+ // We wait for the promise to resolve.
552
+ // Once triggered, the rest of the init function runs
553
+ await map.onReadyAsync();
554
+
555
+ // Adding a data source
556
+ map.addSource('my-gps-track-source', {
557
+ type: "geojson",
558
+ data: "https://example.com/some-gps-track.geojson",
559
+ });
560
+ }
561
+ ```
562
+
497
563
  We believe that the *promise* approach is better because it does not nest scopes and will allow for a linear non-nested stream of execution. It also corresponds to more modern development standards.
498
564
 
499
- > 📣 *__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` and `loadWithTerrain` events.
565
+ > 📣 *__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.
500
566
 
501
567
  # Color Ramps
502
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.
@@ -795,6 +861,16 @@ Turning off *zoom compensation* allows for more accurate adjustments to the visu
795
861
 
796
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/).
797
863
 
864
+ # Caching
865
+ 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
+ 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
+
869
+ ```ts
870
+ import { config } from "@maptiler/sdk";
871
+
872
+ config.caching = false;
873
+ ```
798
874
 
799
875
  # Easy access to MapTiler Cloud API
800
876
  Our map SDK is not only about maps! We also provide plenty of wrapper to our API calls!
@@ -1061,3 +1137,132 @@ And voila!
1061
1137
  > 📣 *__Note:__* The GeoJSON for this track contains 9380 couples of coordinates, which is a lot! In order to send the track to MapTiler Cloud static maps API, the client simplifies the long paths while keeping a high degree of precision using a very fast [Ramer-Douglas-Peucker algorithm](https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm).
1062
1138
 
1063
1139
  Read more about bounded static maps on our official [API documentation](https://docs.maptiler.com/cloud/api/static-maps/#auto-fitted-image).
1140
+
1141
+ ## 🏔️ 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
+
1144
+ > ℹ️ 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
+ > 📣 Note for **TypeScript** users: internaly, the elevation feature relies on some *GeoJSON* types definitions that can be found in this NPM package: `@types/geojson`. Namely `LineString`, `MultiLineString` and `Position`. It may improve your developer experience to also use these types.
1147
+
1148
+ Let's see how to use it:
1149
+
1150
+ ### At a single location
1151
+ ```ts
1152
+ // Not mandatory, but it's to explain where the type comes from:
1153
+ import { Position } from "geojson";
1154
+
1155
+ const montBlancPeak: Position = [6.864884, 45.832743];
1156
+ const elevatedPosition = await maptilersdk.elevation.at(montBlancPeak);
1157
+ ```
1158
+ The returned value is also a *GeoJSON* `Position` array, but with three elements: `[lng, lat, elevation]`.
1159
+
1160
+ Read more about elevation lookup for a single location in our [official documentation](https://docs.maptiler.com/client-js/elevation/#at).
1161
+
1162
+ ### Batch mode
1163
+ ```ts
1164
+ // Not mandatory, but it's to explain where the type comes from:
1165
+ import { Position } from "geojson";
1166
+
1167
+ const peaks: Position[] = [
1168
+ [6.864884, 45.832743], // Mont Blanc, Alps
1169
+ [86.9250, 27.9881], // Mount Everest, Himalayas
1170
+ [-70.0109, -32.6532], // Aconcagua, Andes
1171
+ [-151.0064, 63.0695], // Denali, Alaska
1172
+ [37.3556, -3.0674], // Mount Kilimanjaro
1173
+ [42.4453, 43.3499], // Mount Elbrus, Caucasus
1174
+ [137.1595, -4.0784], // Puncak Jaya, Sudirman Range
1175
+ [-140.4055, 60.5672], // Mount Logan, Saint Elias Mountains
1176
+ [138.73111, 35.358055], // Mount Fuji
1177
+ ];
1178
+
1179
+ const elevatedPeaks = await maptilersdk.elevation.batch(peaks);
1180
+ ```
1181
+
1182
+ Read more about elevation lookup for a batch of locations in our [official documentation](https://docs.maptiler.com/client-js/elevation/#batch).
1183
+
1184
+ ### 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
+
1187
+ ```ts
1188
+ // Not mandatory, but it's to explain where the type comes from:
1189
+ import { LineString } from "geojson";
1190
+
1191
+
1192
+ const someLineString: LineString = {
1193
+ type: "LineString",
1194
+ coordinates: [[6.864884, 45.832743], [86.9250, 27.9881], [-70.0109, -32.6532]]
1195
+ };
1196
+
1197
+ const someElevatedLineString = await maptilersdk.elevation.fromLineString(someLineString);
1198
+ // someElevatedLineString is also of type LineString
1199
+ ```
1200
+
1201
+ Read more about elevation lookup for a `LineString` in our [official documentation](https://docs.maptiler.com/client-js/elevation/#linestring).
1202
+
1203
+ ### 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
+
1206
+ ```ts
1207
+ // Not mandatory, but it's to explain where the type comes from:
1208
+ import { MultiLineString } from "geojson";
1209
+
1210
+
1211
+ const someMultiLineString: MultiLineString = {
1212
+ type: "LineString",
1213
+ coordinates: [
1214
+ [[6.864884, 45.832743], [86.9250, 27.9881], [-70.0109, -32.6532]],
1215
+ [[-151.0064, 63.0695], [37.3556, -3.0674], [42.4453, 43.3499]],
1216
+ [[137.1595, -4.0784], [-140.4055, 60.5672], [138.73111, 35.358055]],
1217
+ ]
1218
+ };
1219
+
1220
+ const someElevatedMultiLineString = await maptilersdk.elevation.fromMultiLineString(someMultiLineString);
1221
+ // someElevatedMultiLineString is also of type MultiLineString
1222
+ ```
1223
+
1224
+ Read more about elevation lookup for a `MultiLineString` in our [official documentation](https://docs.maptiler.com/client-js/elevation/#multilinestring).
1225
+
1226
+ ### Caching
1227
+ 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
+ ## 🧮 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
+
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
+
1234
+ Here are some examples:
1235
+
1236
+ ```ts
1237
+ // Not mandatory, but it's to explain where the type comes from:
1238
+ import { Position } from "geojson";
1239
+
1240
+ // Some constants
1241
+ const earthRadius = maptilersdk.math.EARTH_RADIUS;
1242
+ const earthCircumference = maptilersdk.math.EARTH_CIRCUMFERENCE;
1243
+
1244
+ const montBlancPeakWgs84: Position = [6.864884, 45.832743];
1245
+
1246
+ // From WGS84 to Mercator
1247
+ const montBlancPeakMerc = maptilersdk.math.wgs84ToMercator(montBlancPeakWgs84); // also of type Position
1248
+
1249
+ // From Mercator to WGS84
1250
+ const montBlancPeakWgs84Again = maptilersdk.math.mercatorToWgs84(montBlancPeakMerc);
1251
+
1252
+ // A great-circle distance in meter:
1253
+ const from: Position = /* ... */;
1254
+ const to: Position = /* ... */;
1255
+ const distance = maptilersdk.math.haversineDistanceWgs84(from, to);
1256
+
1257
+ // Full distance of a route made of many positions
1258
+ const route: Position[] = /* ... */;
1259
+ const totalDistance = maptilersdk.math.haversineCumulatedDistanceWgs84(route);
1260
+
1261
+ // Lon lat to tile index, given a zoom level. An [x, y] array is returned
1262
+ const tileXY = maptilersdk.math.wgs84ToTileIndex(montBlancPeakWgs84, 14);
1263
+ // Possible to have floating point tile indices with a third argument to `false`
1264
+
1265
+ // and many more!
1266
+ ```
1267
+
1268
+ Please find out more about the math package in our [official documentation](https://docs.maptiler.com/client-js/math):
package/CHANGELOG.md DELETED
@@ -1,157 +0,0 @@
1
- # MapTiler SDK Changelog
2
-
3
- ## DEVEL
4
- ### New Features
5
- ### Bug Fixes
6
- ### Others
7
-
8
- ## 1.2.0
9
- ### New Features
10
- - Added the Minimap control https://github.com/maptiler/maptiler-sdk-js/pull/54
11
- - Added vector layer helpers to create easier:
12
- - point layer (https://github.com/maptiler/maptiler-sdk-js/pull/61)
13
- - heatmap layer (https://github.com/maptiler/maptiler-sdk-js/pull/61)
14
- - polyline layer, including parsing from GPX/KML (https://github.com/maptiler/maptiler-sdk-js/pull/51)
15
- - polygon layer (https://github.com/maptiler/maptiler-sdk-js/pull/56)
16
- - 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)
17
- - 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)
18
- ### Bug Fixes
19
- - Fixed type export (https://github.com/maptiler/maptiler-sdk-js/pull/47)
20
- ### Others
21
- - Upgrade to MapLibre v3.5.2 (https://github.com/maptiler/maptiler-sdk-js/pull/63)
22
- - Update of TypeScript configuration `moduleResolution` to `Bundler` (https://github.com/maptiler/maptiler-sdk-js/pull/62)
23
-
24
- ## 1.1.2
25
- ### Bug Fixes
26
- - 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
27
-
28
- ## 1.1.1
29
- ### Others
30
- - Update to `maplibre-gl@3.1.0`
31
-
32
- ## 1.1.0
33
- ### New Features
34
- - Bringing back Map's `options.transformRequest` and `.setTransformRequest()`
35
- ### Bug Fixes
36
- - Fixed the MapTiler logo rel name and its nofollow feature
37
- - Made the few necessary changes acording to updating the ML v3. No braking change for SDK API
38
- ### Others
39
- - Updated from `maplibre-gl@3.0.0-pre.4` to `maplibre-gl@3.0.1` (this includes the switch to WebGL2)
40
-
41
-
42
- ## 1.0.12
43
- ### New Features
44
- - 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`)
45
- ### Bug Fixes
46
- - 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).
47
-
48
- ## 1.0.11
49
- ### Bug Fixes
50
- - Now exporting `MaptilerNavigationControl`
51
- ### Others
52
- - Documentation update for `Map`'s `option.maptilerLogo` that was a bit unclear
53
-
54
- ## 1.0.10
55
- ### New Features
56
- - Terrain growing animation on enabling/disabling
57
- - Added `Map` custom event `loadWithTerrain`
58
- - Added `Map` lifecycle methods `.onLoadAsync()` and `.onLoadWithTerrainAsync()`
59
- ### Others
60
- - Readme section was added about the event an methods above
61
- - Updated from `maplibre-gl@3.0.0-pre.3` to `maplibre-gl@3.0.0-pre.4`
62
- - Updated from `typedoc@0.23.21` to `typedoc@0.24.4`, which changes slightly the look of the reference documentation.
63
- - Updated from `typescript@4.8.4` to `typescript@5.0.4`
64
- - Updated from `rollup@2.79.0` to `rollup@3.20.6` as well as all the Rollup plugins
65
-
66
- ## 1.0.9
67
- ### New Features
68
- - Added new styles:
69
- - `MapStyle.STREETS.NIGHT`
70
- - `MapStyle.WINTER.DARK`
71
- - `MapStyle.OUTDOOR.DARK`
72
- ### Bug Fixes
73
- - If the geolocate option is missing from `Map` constructor, then it's considered `false`
74
- - The instance types for the following MapLibre classes are now fully exported:
75
- - `NavigationControl`
76
- - `GeolocateControl`
77
- - `AttributionControl`
78
- - `LogoControl`
79
- - `ScaleControl`
80
- - `FullscreenControl`
81
- - `TerrainControl`
82
- - `Popup`
83
- - `Marker`
84
- - `Style`
85
- - `LngLat`
86
- - `LngLatBounds`
87
- - `MercatorCoordinate`
88
- - `Evented`
89
- - `AJAXError`
90
- - `CanvasSource`
91
- - `GeoJSONSource`
92
- - `ImageSource`
93
- - `RasterDEMTileSource`
94
- - `RasterTileSource`
95
- - `VectorTileSource`
96
- - `VideoSource`
97
- - `MapMLGL`
98
- - The following class have been extended to provide greater compatibility with SDK,s MapL
99
- - `Popup`
100
- - `Marker`
101
- - `Style`
102
- - `CanvasSource`
103
- - `GeoJSONSource`
104
- - `ImageSource`
105
- - `RasterDEMTileSource`
106
- - `RasterTileSource`
107
- - `VectorTileSource`
108
- - `VideoSource`
109
- - `NavigationControl`
110
- - `GeolocateControl`
111
- - `AttributionControl`
112
- - `LogoControl`
113
- - `ScaleControl`
114
- - `FullscreenControl`
115
- - `TerrainControl`
116
-
117
-
118
- ## 1.0.8
119
- ### Bug Fixes
120
- - Since v1.0.7, the `Map` primary language (when custom) was no longer persistant on style update.
121
-
122
- ## 1.0.7
123
- ### New Features
124
- - The `apiKey` can now be specified in the `Map` constructor (will propagate to `config`)
125
- - The `language` can now be speficifed in the `Map` constructo (will **not** propagete to `config` and will apply only to this specific instance)
126
- - `Map` now has the method `.getSdkConfig()` to retrieve the config object.
127
- - `Map` now has the method `.getMaptilerSessionId()` to retrieve the MapTiler session ID
128
- 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.
129
-
130
- ## 1.0.6
131
- ### New Features
132
- - Now exposing `MaptilerGeolocateControl` for external initialization if needed
133
- - Now exposing `MaptilerTerrain` for external initialization if needed
134
-
135
- ## 1.0.5
136
- ### New Features
137
- - Terrain elevation is now using MapTiler's `terrain-rgb-v2`
138
-
139
- ## 1.0.4
140
- ### Others
141
- - Improved the geolocate control behavior by not zooming out
142
-
143
- ## 1.0.3
144
- ### Bug Fixes
145
- - Fixed the usage of relative path style JSON (in `Map` constructor and `.setStyle()`)
146
-
147
- ## 1.0.2
148
- ### Bug Fixes
149
- - Fixed the dependency scheme of MapLibre import.
150
-
151
- ## 1.0.1
152
- ### Others
153
- - Reducing the NPM size by ignoring documentation images
154
-
155
- ## 1.0.0
156
- ### Others
157
- - First public version!
package/colorramp.md DELETED
@@ -1,93 +0,0 @@
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
- ![](images/plot_linear_gradient.jpg)
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
- ![](images/gray_linear.png)
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
- ![](images/plot_sqrt_gradient.jpg)
49
-
50
- This will yield the following color ramp:
51
-
52
- ![](images/gray_sqrt.png)
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
- ![](images/linear_on_sqrt.jpg)
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
- ![](images/plot_square_gradient.jpg)
77
-
78
- This will yield the following color ramp:
79
-
80
- ![](images/gray_square.png)
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
- ![](images/linear_on_square.jpg)
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.