basemapkit 0.4.1 → 0.5.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 +5 -0
- package/dist/basemapkit.js +35 -35
- package/dist/basemapkit.js.map +1 -1
- package/package.json +1 -1
- package/readme.md +18 -3
package/dist/basemapkit.d.ts
CHANGED
|
@@ -204,6 +204,11 @@ export type GetStyleOptions = {
|
|
|
204
204
|
*/
|
|
205
205
|
exaggeration?: number;
|
|
206
206
|
};
|
|
207
|
+
/**
|
|
208
|
+
* Use the globe projection if `true`, Mercator if `false`.
|
|
209
|
+
* Default: `true`
|
|
210
|
+
*/
|
|
211
|
+
globe?: boolean;
|
|
207
212
|
};
|
|
208
213
|
/**
|
|
209
214
|
* Identifier of the terrain source within the Basemapkit source definition
|
package/dist/basemapkit.js
CHANGED
|
@@ -27,27 +27,27 @@ function S(n, e) {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function $(n, e) {
|
|
31
31
|
const i = n / 255, t = i + (1 - i) * i * e;
|
|
32
32
|
return Math.max(0, Math.min(255, t * 255));
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
return n.map((i) =>
|
|
34
|
+
function D(n, e) {
|
|
35
|
+
return n.map((i) => $(i, e));
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function P(n, e, i = 127) {
|
|
38
38
|
const t = Math.max(-0.99, Math.min(0.99, e)), r = t < 0 ? t + 1 : 1 / (1 - t), d = i + r * (n - i);
|
|
39
39
|
return Math.round(Math.max(0, Math.min(255, d)));
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
return n.map((t) =>
|
|
41
|
+
function F(n, e, i = 127) {
|
|
42
|
+
return n.map((t) => P(t, e, i));
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function W(n, e, i = 1) {
|
|
45
45
|
return 255 * (n / 255) * (e / 255) * i + n / 255 * (1 - i) * 255;
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
return n.map((t, r) =>
|
|
47
|
+
function U(n, e, i = 1) {
|
|
48
|
+
return n.map((t, r) => W(n[r], e[r], i));
|
|
49
49
|
}
|
|
50
|
-
const
|
|
50
|
+
const Y = `[
|
|
51
51
|
{
|
|
52
52
|
"id": "background",
|
|
53
53
|
"type": "background",
|
|
@@ -2265,7 +2265,7 @@ const U = `[
|
|
|
2265
2265
|
}
|
|
2266
2266
|
}
|
|
2267
2267
|
|
|
2268
|
-
]`,
|
|
2268
|
+
]`, J = `[
|
|
2269
2269
|
{
|
|
2270
2270
|
"id": "background",
|
|
2271
2271
|
"type": "background",
|
|
@@ -3456,7 +3456,7 @@ const U = `[
|
|
|
3456
3456
|
"text-halo-width": 1.1
|
|
3457
3457
|
}
|
|
3458
3458
|
}
|
|
3459
|
-
]`,
|
|
3459
|
+
]`, q = `[
|
|
3460
3460
|
{
|
|
3461
3461
|
"id": "background",
|
|
3462
3462
|
"type": "background",
|
|
@@ -4682,7 +4682,7 @@ const U = `[
|
|
|
4682
4682
|
"text-halo-width": 1.5
|
|
4683
4683
|
}
|
|
4684
4684
|
}
|
|
4685
|
-
]`,
|
|
4685
|
+
]`, H = `[
|
|
4686
4686
|
{
|
|
4687
4687
|
"id": "background",
|
|
4688
4688
|
"type": "background",
|
|
@@ -5158,7 +5158,7 @@ const U = `[
|
|
|
5158
5158
|
"text-halo-color": "rgba(0, 255, 0, 0.8)"
|
|
5159
5159
|
}
|
|
5160
5160
|
}
|
|
5161
|
-
]`,
|
|
5161
|
+
]`, Q = `[
|
|
5162
5162
|
{
|
|
5163
5163
|
"id": "background",
|
|
5164
5164
|
"type": "background",
|
|
@@ -6355,16 +6355,16 @@ function I(n, e) {
|
|
|
6355
6355
|
}
|
|
6356
6356
|
return !0;
|
|
6357
6357
|
}
|
|
6358
|
-
function
|
|
6358
|
+
function V() {
|
|
6359
6359
|
const n = Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0];
|
|
6360
6360
|
return I(n, void 0) ? n : "en";
|
|
6361
6361
|
}
|
|
6362
6362
|
const x = {
|
|
6363
|
-
avenue:
|
|
6364
|
-
bureau:
|
|
6365
|
-
journal:
|
|
6366
|
-
monochrome:
|
|
6367
|
-
spectre:
|
|
6363
|
+
avenue: Y,
|
|
6364
|
+
bureau: J,
|
|
6365
|
+
journal: q,
|
|
6366
|
+
monochrome: Q,
|
|
6367
|
+
spectre: H
|
|
6368
6368
|
}, R = {
|
|
6369
6369
|
"avenue-pop": {
|
|
6370
6370
|
baseStyle: "avenue",
|
|
@@ -6693,7 +6693,7 @@ const x = {
|
|
|
6693
6693
|
}
|
|
6694
6694
|
}
|
|
6695
6695
|
}, E = "__bmk_bm_src", v = "__bmk_tr_src";
|
|
6696
|
-
function
|
|
6696
|
+
function on() {
|
|
6697
6697
|
const n = [];
|
|
6698
6698
|
for (const e of Object.keys(x)) {
|
|
6699
6699
|
n.push(e);
|
|
@@ -6702,7 +6702,7 @@ function en() {
|
|
|
6702
6702
|
}
|
|
6703
6703
|
return n;
|
|
6704
6704
|
}
|
|
6705
|
-
function
|
|
6705
|
+
function ln(n, e) {
|
|
6706
6706
|
if (n in x)
|
|
6707
6707
|
return G({
|
|
6708
6708
|
...e,
|
|
@@ -6726,7 +6726,7 @@ function G(n) {
|
|
|
6726
6726
|
else if (typeof n.lang == "string" && I(n.lang, n.script))
|
|
6727
6727
|
e = JSON.stringify(j(n.lang, n.script)), i = JSON.stringify(A(n.lang, n.script));
|
|
6728
6728
|
else {
|
|
6729
|
-
const s =
|
|
6729
|
+
const s = V();
|
|
6730
6730
|
e = JSON.stringify(j(s)), i = JSON.stringify(A(s));
|
|
6731
6731
|
}
|
|
6732
6732
|
if (!(n.baseStyleName in x))
|
|
@@ -6754,7 +6754,7 @@ function G(n) {
|
|
|
6754
6754
|
}
|
|
6755
6755
|
p = p.filter((a) => a.id === "pois" || a.type !== "symbol" ? !0 : !(a.layout !== void 0 && a.layout["text-field"] !== void 0));
|
|
6756
6756
|
}
|
|
6757
|
-
const o = n.colorEdit ?? {}, h = o.brightness ?? 0, k = o.hueRotation ?? 0, M = o.saturation ?? 0, K = o.negate ?? !1, B = o.brightnessShift ?? 0, w = o.exposure ?? 0;
|
|
6757
|
+
const o = n.colorEdit ?? {}, h = o.brightness ?? 0, k = o.hueRotation ?? 0, M = o.saturation ?? 0, K = o.negate ?? !1, B = o.brightnessShift ?? 0, w = o.exposure ?? 0, O = { type: n.globe ?? !0 ? "globe" : "mercator" };
|
|
6758
6758
|
return (h !== 0 || k !== 0 || M !== 0 || K === !0 || o.multiplyColor !== void 0 || o.mixColor !== void 0 || B !== 0 || o.contrast !== void 0 || w !== 0) && S(p, (s) => {
|
|
6759
6759
|
let a = b(s);
|
|
6760
6760
|
if (K && (a = a.negate()), k !== 0 && (a = a.rotate(k)), M !== 0 && (a = a.saturate(M)), h > 0 ? a = a.lighten(h) : h < 0 && (a = a.darken(h * -1)), B !== 0) {
|
|
@@ -6762,17 +6762,17 @@ function G(n) {
|
|
|
6762
6762
|
f[2] += B * 100, a = b.hsl(...f);
|
|
6763
6763
|
}
|
|
6764
6764
|
Array.isArray(o.mixColor) && typeof o.mixColor[0] == "string" && typeof o.mixColor[1] == "number" && o.mixColor[1] !== 0 && (a = a.mix(b(o.mixColor[0]), o.mixColor[1]));
|
|
6765
|
-
const u = a.rgb(),
|
|
6765
|
+
const u = a.rgb(), T = u.alpha();
|
|
6766
6766
|
let y = [u.red(), u.green(), u.blue()];
|
|
6767
|
-
if (w !== 0 && (y =
|
|
6767
|
+
if (w !== 0 && (y = D(y, w)), Array.isArray(o.contrast) && typeof o.contrast[0] == "number" && typeof o.contrast[1] == "number" && o.contrast[0] !== 0 && (y = F(y, o.contrast[0], o.contrast[1])), Array.isArray(o.multiplyColor) && typeof o.multiplyColor[0] == "string" && typeof o.multiplyColor[1] == "number" && o.multiplyColor[1] !== 0) {
|
|
6768
6768
|
const f = b(o.multiplyColor[0]);
|
|
6769
|
-
y =
|
|
6769
|
+
y = U(
|
|
6770
6770
|
y,
|
|
6771
6771
|
[f.red(), f.green(), f.blue()],
|
|
6772
6772
|
o.multiplyColor[1]
|
|
6773
6773
|
);
|
|
6774
6774
|
}
|
|
6775
|
-
const z = b({ r: y[0], g: y[1], b: y[2], alpha:
|
|
6775
|
+
const z = b({ r: y[0], g: y[1], b: y[2], alpha: T });
|
|
6776
6776
|
return s.startsWith("rgba(") || s.startsWith("rgb(") ? z.rgb().toString() : s.startsWith("hsl(") || s.startsWith("hsla(") ? z.hsl().toString() : z.hexa();
|
|
6777
6777
|
}), {
|
|
6778
6778
|
version: 8,
|
|
@@ -6795,7 +6795,7 @@ function G(n) {
|
|
|
6795
6795
|
} : {}
|
|
6796
6796
|
},
|
|
6797
6797
|
layers: p,
|
|
6798
|
-
projection:
|
|
6798
|
+
projection: O,
|
|
6799
6799
|
// Add the terrain if the terrain source is provided and the exaggeration is superior to 0
|
|
6800
6800
|
...c && g ? {
|
|
6801
6801
|
terrain: {
|
|
@@ -6805,7 +6805,7 @@ function G(n) {
|
|
|
6805
6805
|
} : {}
|
|
6806
6806
|
};
|
|
6807
6807
|
}
|
|
6808
|
-
function
|
|
6808
|
+
function an(n, e, i) {
|
|
6809
6809
|
const t = i.layers.map((m) => m.id);
|
|
6810
6810
|
if (n === e)
|
|
6811
6811
|
throw new Error("The provided layers must have different IDs.");
|
|
@@ -6815,7 +6815,7 @@ function on(n, e, i) {
|
|
|
6815
6815
|
const l = structuredClone(i), c = l.layers[r], _ = l.layers[d];
|
|
6816
6816
|
return l.layers.splice(r, 1, _), l.layers.splice(d, 1, c), l;
|
|
6817
6817
|
}
|
|
6818
|
-
function
|
|
6818
|
+
function rn(n, e, i) {
|
|
6819
6819
|
const r = i.layers.map((_) => _.id).indexOf(n);
|
|
6820
6820
|
if (r === -1)
|
|
6821
6821
|
throw new Error(`The layer with ID ${n} does not exist in the provided style.`);
|
|
@@ -6858,9 +6858,9 @@ export {
|
|
|
6858
6858
|
E as BASEMAPKIT_BASEMAP_SOURCE_ID,
|
|
6859
6859
|
v as BASEMAPKIT_TERRAIN_SOURCE_ID,
|
|
6860
6860
|
G as buildStyle,
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6861
|
+
ln as getStyle,
|
|
6862
|
+
on as getStyleList,
|
|
6863
|
+
rn as setLayerOpacity,
|
|
6864
|
+
an as swapLayers
|
|
6865
6865
|
};
|
|
6866
6866
|
//# sourceMappingURL=basemapkit.js.map
|