basemapkit 0.1.4 โ 0.3.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/dist/basemapkit.d.ts +38 -0
- package/dist/basemapkit.js +263 -1196
- package/dist/basemapkit.js.map +1 -1
- package/package.json +1 -1
- package/readme.md +83 -4
- package/vite.config-lib.ts +1 -0
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -16,8 +16,11 @@ Basemaps for <a href="https://maplibre.org/maplibre-gl-js/docs/">Maplibre GL JS<
|
|
|
16
16
|
|  |  |  |
|
|
17
17
|
|  | |  |
|
|
18
18
|
|  |  |  |
|
|
19
|
+
|  |  |  |
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+

|
|
22
|
+
|
|
23
|
+
## Getting started ๐ท
|
|
21
24
|
### Install
|
|
22
25
|
On an existing ES project:
|
|
23
26
|
```bash
|
|
@@ -67,6 +70,7 @@ const map = new maplibregl.Map({
|
|
|
67
70
|
```
|
|
68
71
|
|
|
69
72
|
If using a traditional `tile.json` and `z/x/y` tiles instead of http-range-requesting a `pmtiles` file, then replace the option `pmtiles` by `tilejson`, as in the example below:
|
|
73
|
+
|
|
70
74
|
```ts
|
|
71
75
|
const style = getStyle(
|
|
72
76
|
// One of the main syle:
|
|
@@ -87,7 +91,7 @@ const style = getStyle(
|
|
|
87
91
|
```
|
|
88
92
|
This can get particularly handy when using the [Protomaps CLI](https://docs.protomaps.com/pmtiles/cli) or [Martin](https://martin.maplibre.org/) to serve `z/x/y` vector tiles.
|
|
89
93
|
|
|
90
|
-
## Language
|
|
94
|
+
## Language ๐ฃ
|
|
91
95
|
Basemakit styles are compatible with Protomaps languages properties and uses [`@protomaps/basemaps`](https://docs.protomaps.com/basemaps/flavors) under the hood.
|
|
92
96
|
|
|
93
97
|
The only addition from **Basemapkit** is the capability to detect the end user's platform language, so if the `lang` option is omitted, it will automatically use the language set by the user at the browser or OS level.
|
|
@@ -97,7 +101,82 @@ Here is the list of supported languages:
|
|
|
97
101
|
"ar" | "cs" | "bg" | "da" | "de" | "el" | "en" | "es" | "et" | "fa" | "fi" | "fr" | "ga" | "he" | "hi" | "hr" | "hu" | "id" | "it" | "ja" | "ko" | "lt" | "lv" | "ne" | "nl" | "no" | "mr" | "mt" | "pl" | "pt" | "ro" | "ru" | "sk" | "sl" | "sv" | "tr" | "uk" | "ur" | "vi" | "zh-Hans" | "zh-Hant"
|
|
98
102
|
```
|
|
99
103
|
|
|
100
|
-
##
|
|
104
|
+
## Terrain ๐๏ธ
|
|
105
|
+
Basemapkit can feature hillshading and/or terrain bumps when a terrain tileset is provided. The terrain tiles can be encoded as `"mapbox"` (default) or `"terrarium"`, in either PNG or WebP format. Then, the terrain tileset can be packed as *pmtiles* (``options.terrain.pmtiles`) or left as individual tiles, using a *tiles.json* as entry point (`options.terrain.tilejson`).
|
|
106
|
+
|
|
107
|
+
| | | | | |
|
|
108
|
+
| :----------------: | :------: | :----: | :------: | :----: |
|
|
109
|
+
|  |  |  |  |  |
|
|
110
|
+
|
|
111
|
+

|
|
112
|
+
|
|
113
|
+
Here is how to add hillshading but keep the terrain flat. Those settings are actually the default when the terrain tiles are provided.
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
const style = getStyle(
|
|
117
|
+
"avenue",
|
|
118
|
+
{
|
|
119
|
+
pmtiles: "",
|
|
120
|
+
sprite: "...",
|
|
121
|
+
glyphs: "...";
|
|
122
|
+
lang: "...",
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The terrain options:
|
|
126
|
+
*/
|
|
127
|
+
terrain: {
|
|
128
|
+
/**
|
|
129
|
+
* The public URL of a pmtiles files for raster terrain, encoded on RGB channels of either PNG or WebP. To use if sourcing tiles directly with
|
|
130
|
+
* range-request using the `pmtiles`'s protocol. Alternatively, the option `tileJson` can be used and will take precedence.
|
|
131
|
+
*/
|
|
132
|
+
pmtiles: "https://my-s3-bucket.com/terrain.pmtiles";
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Enable or disable the hillshading. Enabled by default if one of the source options `terrain.pmtiles` or `terrain.tilejson` is provided.
|
|
136
|
+
* It cannot be enabled if none of the source option is provided.
|
|
137
|
+
*/
|
|
138
|
+
hillshading: true,
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The terrain exaggeration is disabled by default, making the terrain flat even if one of the source options `terrain.pmtiles` or `terrain.tilejson` is provided.
|
|
142
|
+
* A value of `1` produces at-scale realistic terrain elevation.
|
|
143
|
+
* It cannot be enabled if none of the source option is provided.
|
|
144
|
+
*/
|
|
145
|
+
exaggeration: 0,
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Encoding of the terrain raster data. Can be "mapbox" or "terrarium". Default: "mapbox"
|
|
149
|
+
*/
|
|
150
|
+
encoding: "mapbox",
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Alternatively, if the terrain tiles are refered to with a `tiles.json`:
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
const style = getStyle(
|
|
159
|
+
"avenue",
|
|
160
|
+
{
|
|
161
|
+
pmtiles: "",
|
|
162
|
+
sprite: "...",
|
|
163
|
+
glyphs: "...";
|
|
164
|
+
lang: "...",
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The terrain options:
|
|
168
|
+
*/
|
|
169
|
+
terrain: {
|
|
170
|
+
/**
|
|
171
|
+
* The public URL to a tile JSON file for raster terrain tiles, encoded on RGB channels of either PNG or WebP. To use if classic z/x/y MVT tiles are served through
|
|
172
|
+
* Maplibre's Martin or the pmtiles CLI. Will take precedence on the option `pmtiles` if both are provided.
|
|
173
|
+
*/
|
|
174
|
+
tilejson: "https://example.com/terrain-tile.json";
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## POIs and labels ๐
|
|
101
180
|
There are options to hide the points of interests and labels. By default, both are shown, meaning the options goes like this:
|
|
102
181
|
```ts
|
|
103
182
|
getStyle(
|
|
@@ -172,6 +251,7 @@ buildStyle({
|
|
|
172
251
|
pmtiles: "...",
|
|
173
252
|
sprite: "...",
|
|
174
253
|
glyphs: "...",
|
|
254
|
+
terrain: {...},
|
|
175
255
|
hidePOIs: false,
|
|
176
256
|
hideLabels: false,
|
|
177
257
|
|
|
@@ -265,7 +345,6 @@ You can live play with these on [basemapkit.jnth.io](https://s.jnth.io/s/basemap
|
|
|
265
345
|
And from this "color editor" were created the built-in styles available below...
|
|
266
346
|
|
|
267
347
|
|
|
268
|
-
|
|
269
348
|
## Style presets available
|
|
270
349
|
Some custom `colorEdit` recipes are already built in Basemapkit and can be accessed directly from the `getStyle()` function.
|
|
271
350
|
### `avenue` โคต๏ธ
|