@maptiler/sdk 1.1.1 → 1.2.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/.eslintrc.cjs +15 -5
- package/.github/pull_request_template.md +11 -0
- package/.github/workflows/format-lint.yml +24 -0
- package/CHANGELOG.md +94 -51
- package/colorramp.md +93 -0
- package/dist/maptiler-sdk.d.ts +1207 -123
- package/dist/maptiler-sdk.min.mjs +3 -1
- package/dist/maptiler-sdk.mjs +3561 -485
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/maptiler-sdk.umd.js +3825 -869
- 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 +298 -0
- package/rollup.config.js +2 -16
- package/src/Map.ts +489 -357
- 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 +10 -0
- 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maptiler/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.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",
|
|
@@ -8,10 +8,14 @@
|
|
|
8
8
|
"type": "module",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"import": "./dist/maptiler-sdk.mjs"
|
|
11
|
+
"import": "./dist/maptiler-sdk.mjs",
|
|
12
|
+
"types": "./dist/maptiler-sdk.d.ts"
|
|
12
13
|
},
|
|
13
14
|
"./dist/maptiler-sdk.css": {
|
|
14
15
|
"import": "./dist/maptiler-sdk.css"
|
|
16
|
+
},
|
|
17
|
+
"./style.css": {
|
|
18
|
+
"import": "./dist/maptiler-sdk.css"
|
|
15
19
|
}
|
|
16
20
|
},
|
|
17
21
|
"keywords": [
|
|
@@ -32,20 +36,28 @@
|
|
|
32
36
|
"scripts": {
|
|
33
37
|
"build": "rm -rf dist/* && NODE_ENV=production rollup -c",
|
|
34
38
|
"dev": "rm -rf dist/* && NODE_ENV=development rollup -c -w",
|
|
35
|
-
"format": "prettier --write \"src/**/*.{js,ts,tsx}\"",
|
|
36
|
-
"
|
|
39
|
+
"format:fix": "prettier --write \"src/**/*.{js,ts,tsx}\"",
|
|
40
|
+
"format": "prettier -c \"src/**/*.{js,ts,tsx}\"",
|
|
41
|
+
"lint:fix": "eslint --fix \"src/**/*.{js,ts}\"",
|
|
42
|
+
"lint": "eslint \"src/**/*.{js,ts}\"",
|
|
37
43
|
"doc": "rm -rf docs/* && typedoc --out docs && cp -r images docs/",
|
|
38
|
-
"prepare": "npm run format && npm run lint && npm run build && npm run
|
|
44
|
+
"prepare": "npm run format:fix && npm run lint:fix && npm run build && npm run test",
|
|
45
|
+
"test:dev": "vitest dev",
|
|
46
|
+
"test": "vitest run"
|
|
39
47
|
},
|
|
40
48
|
"author": "MapTiler",
|
|
41
49
|
"devDependencies": {
|
|
42
50
|
"@rollup/plugin-commonjs": "^24.1.0",
|
|
43
51
|
"@rollup/plugin-json": "^6.0.0",
|
|
44
52
|
"@rollup/plugin-node-resolve": "^15.0.2",
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"eslint": "^
|
|
48
|
-
"
|
|
53
|
+
"@types/uuid": "^9.0.2",
|
|
54
|
+
"@types/xmldom": "^0.1.31",
|
|
55
|
+
"@typescript-eslint/eslint-plugin": "^6.9.0",
|
|
56
|
+
"@typescript-eslint/parser": "^6.9.0",
|
|
57
|
+
"eslint": "^8.52.0",
|
|
58
|
+
"eslint-config-prettier": "^9.0.0",
|
|
59
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
60
|
+
"prettier": "^3.0.3",
|
|
49
61
|
"rollup": "^3.20.6",
|
|
50
62
|
"rollup-plugin-copy-merge": "^1.0.0",
|
|
51
63
|
"rollup-plugin-dts": "^5.3.0",
|
|
@@ -56,14 +68,16 @@
|
|
|
56
68
|
"rollup-plugin-swc": "^0.2.1",
|
|
57
69
|
"serve": "^14.2.0",
|
|
58
70
|
"terser": "^5.17.1",
|
|
59
|
-
"typedoc": "^0.24.
|
|
60
|
-
"typescript": "^5.
|
|
71
|
+
"typedoc": "^0.24.8",
|
|
72
|
+
"typescript": "^5.1.6",
|
|
73
|
+
"vitest": "^0.34.2",
|
|
74
|
+
"xmldom": "^0.6.0"
|
|
61
75
|
},
|
|
62
76
|
"dependencies": {
|
|
63
|
-
"@maptiler/client": "^1.
|
|
77
|
+
"@maptiler/client": "^1.7.0",
|
|
64
78
|
"events": "^3.3.0",
|
|
65
79
|
"js-base64": "^3.7.4",
|
|
66
|
-
"maplibre-gl": "
|
|
80
|
+
"maplibre-gl": "3.5.2",
|
|
67
81
|
"uuid": "^9.0.0"
|
|
68
82
|
}
|
|
69
83
|
}
|
package/readme.md
CHANGED
|
@@ -498,6 +498,304 @@ We believe that the *promise* approach is better because it does not nest scopes
|
|
|
498
498
|
|
|
499
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.
|
|
500
500
|
|
|
501
|
+
# Color Ramps
|
|
502
|
+
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.
|
|
503
|
+
|
|
504
|
+
Color ramps are super useful to represent numerical data in a visual way: the temperature, the population density, the average commute time, etc.
|
|
505
|
+
|
|
506
|
+
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:
|
|
507
|
+
|
|
508
|
+

|
|
509
|
+
|
|
510
|
+
To use an already existing color ramp and access some of its values:
|
|
511
|
+
```ts
|
|
512
|
+
import { ColorRampCollection } from "@maptiler/sdk";
|
|
513
|
+
|
|
514
|
+
// The TURBO color ramp, just like all the built-ins, is defined in [0, 1],
|
|
515
|
+
// but we can rescale it to fit the range of temperature [-18, 38]°C (equivalent to [0, 100]F)
|
|
516
|
+
// and this actually creates a clone of the original TURBO
|
|
517
|
+
const temperatureTurbo = ColorRampCollection.TURBO.scale(-18, 38);
|
|
518
|
+
|
|
519
|
+
// What's the color at 0°C (or 32F) ?
|
|
520
|
+
const zeroColor = temperatureTurbo.getColor(0);
|
|
521
|
+
// The color is an array: [45, 218, 189, 255]
|
|
522
|
+
|
|
523
|
+
// Alternatively, we can ask for the hex color:
|
|
524
|
+
const zeroColorHex = temperatureTurbo.getColorHex(0);
|
|
525
|
+
// The color is a string: "#2ddabdff"
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
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:
|
|
529
|
+
|
|
530
|
+
```ts
|
|
531
|
+
import { ColorRamp } from "@maptiler/sdk";
|
|
532
|
+
|
|
533
|
+
const myCustomRamp = new ColorRamp({
|
|
534
|
+
stops: [
|
|
535
|
+
{ value: 0, color: [68, 1, 84] },
|
|
536
|
+
{ value: 13, color: [71, 44, 122] },
|
|
537
|
+
{ value: 25, color: [59, 81, 139] },
|
|
538
|
+
{ value: 38, color: [44, 113, 142] },
|
|
539
|
+
{ value: 5, color: [33, 144, 141] },
|
|
540
|
+
{ value: 63, color: [39, 173, 129] },
|
|
541
|
+
{ value: 75, color: [92, 200, 99] },
|
|
542
|
+
{ value: 88, color: [170, 220, 50] },
|
|
543
|
+
{ value: 100, color: [253, 231, 37] },
|
|
544
|
+
]
|
|
545
|
+
});
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
When defining a new *ramp*, the colors can be a RGB array (`[number, number, number]`) or a RGBA array (`[number, number, number, number]`).
|
|
549
|
+
|
|
550
|
+
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.
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
# Vector Layer Helpers
|
|
554
|
+
**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!** 🖋️
|
|
555
|
+

|
|
556
|
+
|
|
557
|
+
## Shared logic
|
|
558
|
+
Helpers come with a lot of **built-in defaults** and some fail-proof logic that makes creating vector layers much easier! As a result, a dataset can be displayed in one call, creating both the datasource and the layer(s) in one go!
|
|
559
|
+
|
|
560
|
+
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.
|
|
561
|
+
|
|
562
|
+
All the helpers are made avaialable under the `helpers` object. If you are using ES Modules, this is how you access them:
|
|
563
|
+
```ts
|
|
564
|
+
import { Map, helpers } from "@maptiler/sdk";
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
If you are using the UMD bundle of the SDK, for example from our CDN, you will find the `helpers` with:
|
|
568
|
+
```js
|
|
569
|
+
maptilersdk.helpers
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
**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*.
|
|
573
|
+
|
|
574
|
+
In addition to easy styling, helper's datasource can be:
|
|
575
|
+
- a URL to a geoJSON file or its string content
|
|
576
|
+
- a URL to a GPX or KML file (only for the polyline helper) or its string content
|
|
577
|
+
- a UUID of a MapTiler Cloud dataset
|
|
578
|
+
|
|
579
|
+
### Multiple Layers
|
|
580
|
+
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**.
|
|
581
|
+
|
|
582
|
+
> 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.
|
|
583
|
+
|
|
584
|
+
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.
|
|
585
|
+
|
|
586
|
+
### Input
|
|
587
|
+
|
|
588
|
+
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:
|
|
589
|
+
|
|
590
|
+
```ts
|
|
591
|
+
/**
|
|
592
|
+
* A geojson Feature collection or a URL to a geojson or the UUID of a MapTiler Cloud dataset.
|
|
593
|
+
*/
|
|
594
|
+
data: FeatureCollection | string;
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* ID to give to the layer.
|
|
598
|
+
* If not provided, an auto-generated ID of the for "maptiler-layer-xxxxxx" will be auto-generated,
|
|
599
|
+
* with "xxxxxx" being a random string.
|
|
600
|
+
*/
|
|
601
|
+
layerId?: string;
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* ID to give to the geojson source.
|
|
605
|
+
* If not provided, an auto-generated ID of the for "maptiler-source-xxxxxx" will be auto-generated,
|
|
606
|
+
* with "xxxxxx" being a random string.
|
|
607
|
+
*/
|
|
608
|
+
sourceId?: string;
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* The ID of an existing layer to insert the new layer before, resulting in the new layer appearing
|
|
612
|
+
* visually beneath the existing layer. If this argument is not specified, the layer will be appended
|
|
613
|
+
* to the end of the layers array and appear visually above all other layers.
|
|
614
|
+
*/
|
|
615
|
+
beforeId?: string;
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Zoom level at which it starts to show.
|
|
619
|
+
* Default: `0`
|
|
620
|
+
*/
|
|
621
|
+
minzoom?: number;
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Zoom level after which it no longer show.
|
|
625
|
+
* Default: `22`
|
|
626
|
+
*/
|
|
627
|
+
maxzoom?: number;
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
## Polyline Layer Helper
|
|
633
|
+
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.
|
|
634
|
+
|
|
635
|
+
here is the minimal usage, with the default line width and a random color (withing a selected list):
|
|
636
|
+
```ts
|
|
637
|
+
helpers.addPolyline(map, {
|
|
638
|
+
// A URL, relative or absolute
|
|
639
|
+
data: "some-trace.geojson",
|
|
640
|
+
});
|
|
641
|
+
```
|
|
642
|
+

|
|
643
|
+
|
|
644
|
+
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:
|
|
645
|
+
```ts
|
|
646
|
+
helpers.addPolyline(map, {
|
|
647
|
+
data: "74003ba7-215a-4b7e-8e26-5bbe3aa70b05",
|
|
648
|
+
lineColor: "#FF6666",
|
|
649
|
+
lineWidth: 4,
|
|
650
|
+
lineDashArray: "____ _ ",
|
|
651
|
+
lineCap: "butt",
|
|
652
|
+
});
|
|
653
|
+
```
|
|
654
|
+

|
|
655
|
+
As you can see, we've come up with a fun and easy way to create **dash arrays**, just use *underscores* and *white spaces* and this pattern will repeat!
|
|
656
|
+
|
|
657
|
+
Adding an outline is also pretty straightforward:
|
|
658
|
+
```ts
|
|
659
|
+
helpers.addPolyline(map, {
|
|
660
|
+
data: "74003ba7-215a-4b7e-8e26-5bbe3aa70b05",
|
|
661
|
+
lineColor: "#880000",
|
|
662
|
+
outline: true,
|
|
663
|
+
});
|
|
664
|
+
```
|
|
665
|
+

|
|
666
|
+
|
|
667
|
+
Endless possibilities, what about a glowing wire?
|
|
668
|
+
```ts
|
|
669
|
+
helpers.addPolyline(map, {
|
|
670
|
+
data: "74003ba7-215a-4b7e-8e26-5bbe3aa70b05",
|
|
671
|
+
lineColor: "#fff",
|
|
672
|
+
lineWidth: 1,
|
|
673
|
+
outline: true,
|
|
674
|
+
outlineColor: "#ca57ff",
|
|
675
|
+
outlineWidth: 2,
|
|
676
|
+
outlineWidth: 10,
|
|
677
|
+
outlineBlur: 10,
|
|
678
|
+
outlineOpacity: 0.5,
|
|
679
|
+
});
|
|
680
|
+
```
|
|
681
|
+

|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
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/).
|
|
685
|
+
|
|
686
|
+
## Polygon Layer Helper
|
|
687
|
+
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.
|
|
688
|
+
|
|
689
|
+
Here is a minimalist example, with a half-transparent polygon of Switzerland, from a local file:
|
|
690
|
+
|
|
691
|
+
```ts
|
|
692
|
+
helpers.addPolygon(map, {
|
|
693
|
+
data: "switzerland.geojson",
|
|
694
|
+
fillOpacity: 0.5,
|
|
695
|
+
});
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
Again, if no color is specified, a random one from a list is being picked:
|
|
699
|
+

|
|
700
|
+
|
|
701
|
+
Plenty of options are available to create the interesting thematic visualizations:
|
|
702
|
+
|
|
703
|
+
```ts
|
|
704
|
+
helpers.addPolygon(map, {
|
|
705
|
+
data: "switzerland.geojson",
|
|
706
|
+
pattern: "cheese512.png",
|
|
707
|
+
outline: true,
|
|
708
|
+
outlineWidth: 3,
|
|
709
|
+
outlineColor: "white",
|
|
710
|
+
outlineDashArray: "_ ",
|
|
711
|
+
fillOpacity: 0.7,
|
|
712
|
+
});
|
|
713
|
+
```
|
|
714
|
+

|
|
715
|
+
|
|
716
|
+
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/).
|
|
717
|
+
|
|
718
|
+
## Point Layer Helper
|
|
719
|
+
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.
|
|
720
|
+
|
|
721
|
+
Here is the simplest example, with a dataset loaded from a local file:
|
|
722
|
+
```ts
|
|
723
|
+
helpers.addPoint(map, {
|
|
724
|
+
data: "public-schools.geojson",
|
|
725
|
+
})
|
|
726
|
+
```
|
|
727
|
+
if no color is specified, a random color is used and the default radius is ramped over the zoom level:
|
|
728
|
+

|
|
729
|
+
|
|
730
|
+
Here is the same dataset, but with *point clustering* enabled:
|
|
731
|
+
```ts
|
|
732
|
+
helpers.addPoint(map, {
|
|
733
|
+
data: "public-schools.geojson",
|
|
734
|
+
cluster: true,
|
|
735
|
+
});
|
|
736
|
+
```
|
|
737
|
+
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`):
|
|
738
|
+

|
|
739
|
+
|
|
740
|
+
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:
|
|
741
|
+
```ts
|
|
742
|
+
helpers.addPoint(map, {
|
|
743
|
+
data: "public-schools.geojson",
|
|
744
|
+
property: "students",
|
|
745
|
+
pointColor: ColorRampCollection.PORTLAND.scale(200, 2000).resample("ease-out-sqrt"),
|
|
746
|
+
pointOpacity: 0.8,
|
|
747
|
+
minPointRadius: 6,
|
|
748
|
+
maxPointRadius: 30,
|
|
749
|
+
showLabel: true,
|
|
750
|
+
zoomCompensation: false,
|
|
751
|
+
})
|
|
752
|
+
```
|
|
753
|
+

|
|
754
|
+
|
|
755
|
+
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).
|
|
756
|
+
|
|
757
|
+
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/).
|
|
758
|
+
|
|
759
|
+
## Heatmap Layer Helper
|
|
760
|
+
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!**
|
|
761
|
+
|
|
762
|
+
Here is a minimalist example, using the default built-in `TURBO` color ramp:
|
|
763
|
+
```ts
|
|
764
|
+
helpers.addHeatmap(map, {
|
|
765
|
+
data: "public-schools.geojson",
|
|
766
|
+
});
|
|
767
|
+
```
|
|
768
|
+

|
|
769
|
+
|
|
770
|
+
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:
|
|
771
|
+
```ts
|
|
772
|
+
helpers.addHeatmap(map, {
|
|
773
|
+
data: "public-schools.geojson",
|
|
774
|
+
property: "students",
|
|
775
|
+
// radius: how wide are the blobs
|
|
776
|
+
radius: [
|
|
777
|
+
{propertyValue: 100, value: 15},
|
|
778
|
+
{propertyValue: 800, value: 50},
|
|
779
|
+
],
|
|
780
|
+
// weight: how intense are the blob, as fueled by a property
|
|
781
|
+
weight: [
|
|
782
|
+
{propertyValue: 100, value: 0.1},
|
|
783
|
+
{propertyValue: 800, value: 1},
|
|
784
|
+
],
|
|
785
|
+
// A custom color ramp, must be used with its default interval of [0, 1]
|
|
786
|
+
colorRamp: ColorRampCollection.MAGMA,
|
|
787
|
+
zoomCompensation: false,
|
|
788
|
+
opacity: 0.6,
|
|
789
|
+
// a global factor applied to all the blobs, regardless of the property or zoom
|
|
790
|
+
intensity: 1.2,
|
|
791
|
+
});
|
|
792
|
+
```
|
|
793
|
+

|
|
794
|
+
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.
|
|
795
|
+
|
|
796
|
+
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
|
+
|
|
798
|
+
|
|
501
799
|
# Easy access to MapTiler Cloud API
|
|
502
800
|
Our map SDK is not only about maps! We also provide plenty of wrapper to our API calls!
|
|
503
801
|
|
package/rollup.config.js
CHANGED
|
@@ -10,7 +10,7 @@ import json from '@rollup/plugin-json';
|
|
|
10
10
|
import execute from "rollup-plugin-shell";
|
|
11
11
|
|
|
12
12
|
const outputName = "maptiler-sdk";
|
|
13
|
-
const externals = ["maplibre-gl", "@maptiler/client", "@mapbox/point-geometry", "uuid", "@mapbox/unitbezier", "events", "js-base64"];
|
|
13
|
+
const externals = ["maplibre-gl", "@maptiler/client", "@mapbox/point-geometry", "uuid", "@mapbox/unitbezier", "events", "js-base64", "geojson-validation"];
|
|
14
14
|
|
|
15
15
|
const cssMaplibreFilepath = "node_modules/maplibre-gl/dist/maplibre-gl.css";
|
|
16
16
|
const cssTemplateFilepath = "src/style/style_template.css";
|
|
@@ -28,20 +28,6 @@ const copyCssPlugin = copy({
|
|
|
28
28
|
],
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
const copyUmdBundle = copy({
|
|
32
|
-
targets: [
|
|
33
|
-
{
|
|
34
|
-
src: `dist/${outputName}.umd.js`,
|
|
35
|
-
dest: "demos/",
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
src: `dist/${outputName}.css`,
|
|
39
|
-
dest: "demos/",
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
hook: "writeBundle"
|
|
43
|
-
});
|
|
44
|
-
|
|
45
31
|
|
|
46
32
|
const bundles = [
|
|
47
33
|
// ES module, not minified + sourcemap
|
|
@@ -78,7 +64,7 @@ const bundles = [
|
|
|
78
64
|
globals(),
|
|
79
65
|
json(),
|
|
80
66
|
esbuild(),
|
|
81
|
-
copyUmdBundle,
|
|
67
|
+
// copyUmdBundle,
|
|
82
68
|
],
|
|
83
69
|
output: [
|
|
84
70
|
{
|