maplibre-gl 3.2.2 → 3.3.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/LICENSE.txt +1 -1
- package/README.md +2 -1
- package/build/generate-dist-package.js +7 -2
- package/build/generate-struct-arrays.ts +3 -1
- package/build/generate-style-code.ts +7 -8
- package/build/generate-typings.ts +1 -1
- package/dist/LICENSE.txt +116 -0
- package/dist/maplibre-gl-csp-worker.js +1 -1
- package/dist/maplibre-gl-csp-worker.js.map +1 -1
- package/dist/maplibre-gl-csp.js +1 -1
- package/dist/maplibre-gl-csp.js.map +1 -1
- package/dist/maplibre-gl-dev.js +472 -195
- package/dist/maplibre-gl-dev.js.map +1 -1
- package/dist/maplibre-gl.d.ts +58 -16
- package/dist/maplibre-gl.js +3 -3
- package/dist/maplibre-gl.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +24 -23
- package/src/data/array_types.g.ts +78 -14
- package/src/data/bucket/symbol_attributes.ts +7 -1
- package/src/data/bucket/symbol_bucket.ts +4 -1
- package/src/render/draw_symbol.ts +8 -9
- package/src/render/program.ts +15 -0
- package/src/source/vector_tile_source.ts +0 -1
- package/src/source/video_source.ts +4 -0
- package/src/style/properties.ts +4 -0
- package/src/style/style.ts +14 -8
- package/src/style/style_layer/background_style_layer_properties.g.ts +1 -6
- package/src/style/style_layer/circle_style_layer_properties.g.ts +1 -6
- package/src/style/style_layer/fill_extrusion_style_layer_properties.g.ts +1 -6
- package/src/style/style_layer/fill_style_layer_properties.g.ts +1 -6
- package/src/style/style_layer/heatmap_style_layer_properties.g.ts +1 -6
- package/src/style/style_layer/hillshade_style_layer_properties.g.ts +1 -6
- package/src/style/style_layer/line_style_layer_properties.g.ts +1 -6
- package/src/style/style_layer/raster_style_layer_properties.g.ts +1 -6
- package/src/style/style_layer/symbol_style_layer_properties.g.ts +4 -6
- package/src/style/style_layer/variable_text_anchor.test.ts +117 -0
- package/src/style/style_layer/variable_text_anchor.ts +163 -0
- package/src/symbol/placement.ts +52 -40
- package/src/symbol/symbol_layout.ts +42 -116
- package/src/ui/control/navigation_control.ts +0 -1
- package/src/ui/map.test.ts +37 -8
- package/src/ui/map.ts +14 -13
- package/src/ui/marker.ts +1 -1
- package/src/ui/popup.ts +1 -1
- package/src/util/throttle.ts +7 -3
package/dist/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"
|
|
1
|
+
{"name":"maplibre-gl","type":"commonjs","deprecated":"Please install maplibre-gl from parent directory instead"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "maplibre-gl",
|
|
3
3
|
"description": "BSD licensed community fork of mapbox-gl, a WebGL interactive maps library",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.3.1",
|
|
5
5
|
"main": "dist/maplibre-gl.js",
|
|
6
6
|
"style": "dist/maplibre-gl.css",
|
|
7
7
|
"license": "BSD-3-Clause",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@mapbox/unitbezier": "^0.0.1",
|
|
21
21
|
"@mapbox/vector-tile": "^1.3.1",
|
|
22
22
|
"@mapbox/whoots-js": "^3.1.0",
|
|
23
|
-
"@maplibre/maplibre-gl-style-spec": "^19.
|
|
23
|
+
"@maplibre/maplibre-gl-style-spec": "^19.3.0",
|
|
24
24
|
"@types/geojson": "^7946.0.10",
|
|
25
25
|
"@types/mapbox__point-geometry": "^0.1.2",
|
|
26
26
|
"@types/mapbox__vector-tile": "^1.3.0",
|
|
@@ -42,54 +42,54 @@
|
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@mapbox/mapbox-gl-rtl-text": "^0.2.3",
|
|
44
44
|
"@mapbox/mvt-fixtures": "^3.10.0",
|
|
45
|
-
"@rollup/plugin-commonjs": "^25.0.
|
|
45
|
+
"@rollup/plugin-commonjs": "^25.0.4",
|
|
46
46
|
"@rollup/plugin-json": "^6.0.0",
|
|
47
|
-
"@rollup/plugin-node-resolve": "^15.1
|
|
47
|
+
"@rollup/plugin-node-resolve": "^15.2.1",
|
|
48
48
|
"@rollup/plugin-replace": "^5.0.2",
|
|
49
49
|
"@rollup/plugin-strip": "^3.0.2",
|
|
50
50
|
"@rollup/plugin-terser": "^0.4.3",
|
|
51
|
-
"@rollup/plugin-typescript": "^11.1.
|
|
51
|
+
"@rollup/plugin-typescript": "^11.1.3",
|
|
52
52
|
"@types/benchmark": "^2.1.2",
|
|
53
53
|
"@types/cssnano": "^5.0.0",
|
|
54
54
|
"@types/d3": "^7.4.0",
|
|
55
55
|
"@types/diff": "^5.0.3",
|
|
56
56
|
"@types/earcut": "^2.1.1",
|
|
57
|
-
"@types/eslint": "^8.44.
|
|
57
|
+
"@types/eslint": "^8.44.2",
|
|
58
58
|
"@types/gl": "^6.0.2",
|
|
59
59
|
"@types/glob": "^8.1.0",
|
|
60
60
|
"@types/jest": "^29.5.3",
|
|
61
|
-
"@types/jsdom": "^21.1.
|
|
61
|
+
"@types/jsdom": "^21.1.2",
|
|
62
62
|
"@types/minimist": "^1.2.2",
|
|
63
63
|
"@types/murmurhash-js": "^1.0.4",
|
|
64
64
|
"@types/nise": "^1.4.1",
|
|
65
|
-
"@types/node": "^20.
|
|
65
|
+
"@types/node": "^20.5.7",
|
|
66
66
|
"@types/offscreencanvas": "^2019.7.0",
|
|
67
67
|
"@types/pixelmatch": "^5.2.4",
|
|
68
68
|
"@types/pngjs": "^6.0.1",
|
|
69
|
-
"@types/react": "^18.2.
|
|
69
|
+
"@types/react": "^18.2.21",
|
|
70
70
|
"@types/react-dom": "^18.2.7",
|
|
71
71
|
"@types/request": "^2.48.8",
|
|
72
72
|
"@types/shuffle-seed": "^1.1.0",
|
|
73
73
|
"@types/window-or-global": "^1.0.4",
|
|
74
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
75
|
-
"@typescript-eslint/parser": "^6.
|
|
74
|
+
"@typescript-eslint/eslint-plugin": "^6.4.1",
|
|
75
|
+
"@typescript-eslint/parser": "^6.4.1",
|
|
76
76
|
"address": "^1.2.2",
|
|
77
77
|
"benchmark": "^2.1.4",
|
|
78
78
|
"canvas": "^2.11.2",
|
|
79
79
|
"cssnano": "^6.0.1",
|
|
80
80
|
"d3": "^7.8.5",
|
|
81
81
|
"d3-queue": "^3.0.7",
|
|
82
|
-
"devtools-protocol": "^0.0.
|
|
82
|
+
"devtools-protocol": "^0.0.1188743",
|
|
83
83
|
"diff": "^5.1.0",
|
|
84
84
|
"dts-bundle-generator": "^8.0.1",
|
|
85
|
-
"eslint": "^8.
|
|
85
|
+
"eslint": "^8.48.0",
|
|
86
86
|
"eslint-config-mourner": "^3.0.0",
|
|
87
87
|
"eslint-plugin-html": "^7.1.0",
|
|
88
|
-
"eslint-plugin-import": "^2.28.
|
|
88
|
+
"eslint-plugin-import": "^2.28.1",
|
|
89
89
|
"eslint-plugin-jest": "^27.2.3",
|
|
90
|
-
"eslint-plugin-react": "^7.33.
|
|
90
|
+
"eslint-plugin-react": "^7.33.2",
|
|
91
91
|
"eslint-plugin-tsdoc": "0.2.17",
|
|
92
|
-
"expect": "^29.6.
|
|
92
|
+
"expect": "^29.6.4",
|
|
93
93
|
"gl": "^6.0.2",
|
|
94
94
|
"glob": "^10.3.3",
|
|
95
95
|
"is-builtin-module": "^3.2.1",
|
|
@@ -107,28 +107,28 @@
|
|
|
107
107
|
"pdf-merger-js": "^4.3.0",
|
|
108
108
|
"pixelmatch": "^5.3.0",
|
|
109
109
|
"pngjs": "^7.0.0",
|
|
110
|
-
"postcss": "^8.4.
|
|
110
|
+
"postcss": "^8.4.28",
|
|
111
111
|
"postcss-cli": "^10.1.0",
|
|
112
112
|
"postcss-inline-svg": "^6.0.0",
|
|
113
113
|
"pretty-bytes": "^6.1.1",
|
|
114
|
-
"puppeteer": "^
|
|
114
|
+
"puppeteer": "^21.1.0",
|
|
115
115
|
"react": "^18.2.0",
|
|
116
116
|
"react-dom": "^18.2.0",
|
|
117
|
-
"rollup": "^3.
|
|
117
|
+
"rollup": "^3.28.1",
|
|
118
118
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
119
119
|
"rw": "^1.3.3",
|
|
120
120
|
"semver": "^7.5.4",
|
|
121
121
|
"shuffle-seed": "^1.1.6",
|
|
122
122
|
"source-map-explorer": "^2.5.3",
|
|
123
123
|
"st": "^3.0.0",
|
|
124
|
-
"stylelint": "^15.10.
|
|
124
|
+
"stylelint": "^15.10.3",
|
|
125
125
|
"stylelint-config-standard": "^34.0.0",
|
|
126
126
|
"ts-jest": "^29.1.1",
|
|
127
127
|
"ts-node": "^10.9.1",
|
|
128
|
-
"tslib": "^2.6.
|
|
128
|
+
"tslib": "^2.6.2",
|
|
129
129
|
"typedoc": "^0.24.8",
|
|
130
|
-
"typedoc-plugin-markdown": "^3.
|
|
131
|
-
"typedoc-plugin-missing-exports": "^2.0
|
|
130
|
+
"typedoc-plugin-markdown": "^3.16.0",
|
|
131
|
+
"typedoc-plugin-missing-exports": "^2.1.0",
|
|
132
132
|
"typescript": "^5.1.6"
|
|
133
133
|
},
|
|
134
134
|
"overrides": {
|
|
@@ -159,6 +159,7 @@
|
|
|
159
159
|
"build-benchmarks": "npm run build-dev && rollup --configPlugin @rollup/plugin-typescript -c test/bench/rollup_config_benchmarks.ts",
|
|
160
160
|
"watch-benchmarks": "rollup --configPlugin @rollup/plugin-typescript -c test/bench/rollup_config_benchmarks.ts --watch",
|
|
161
161
|
"start-server": "st --no-cache -H 0.0.0.0 --port 9966 .",
|
|
162
|
+
"start-docs": "docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material",
|
|
162
163
|
"start": "run-p watch-css watch-dev start-server",
|
|
163
164
|
"start-bench": "run-p watch-css watch-benchmarks start-server",
|
|
164
165
|
"lint": "eslint --cache --ext .ts,.tsx,.js,.html --ignore-path .gitignore .",
|
|
@@ -621,10 +621,11 @@ register('StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48', StructArrayLayout2i2ui3ul3u
|
|
|
621
621
|
* [0]: Int16[8]
|
|
622
622
|
* [16]: Uint16[15]
|
|
623
623
|
* [48]: Uint32[1]
|
|
624
|
-
* [52]: Float32[
|
|
624
|
+
* [52]: Float32[2]
|
|
625
|
+
* [60]: Uint16[2]
|
|
625
626
|
*
|
|
626
627
|
*/
|
|
627
|
-
class
|
|
628
|
+
class StructArrayLayout8i15ui1ul2f2ui64 extends StructArray {
|
|
628
629
|
uint8: Uint8Array;
|
|
629
630
|
int16: Int16Array;
|
|
630
631
|
uint16: Uint16Array;
|
|
@@ -646,8 +647,8 @@ class StructArrayLayout8i15ui1ul4f68 extends StructArray {
|
|
|
646
647
|
}
|
|
647
648
|
|
|
648
649
|
public emplace(i: number, v0: number, v1: number, v2: number, v3: number, v4: number, v5: number, v6: number, v7: number, v8: number, v9: number, v10: number, v11: number, v12: number, v13: number, v14: number, v15: number, v16: number, v17: number, v18: number, v19: number, v20: number, v21: number, v22: number, v23: number, v24: number, v25: number, v26: number, v27: number) {
|
|
649
|
-
const o2 = i *
|
|
650
|
-
const o4 = i *
|
|
650
|
+
const o2 = i * 32;
|
|
651
|
+
const o4 = i * 16;
|
|
651
652
|
this.int16[o2 + 0] = v0;
|
|
652
653
|
this.int16[o2 + 1] = v1;
|
|
653
654
|
this.int16[o2 + 2] = v2;
|
|
@@ -674,14 +675,14 @@ class StructArrayLayout8i15ui1ul4f68 extends StructArray {
|
|
|
674
675
|
this.uint32[o4 + 12] = v23;
|
|
675
676
|
this.float32[o4 + 13] = v24;
|
|
676
677
|
this.float32[o4 + 14] = v25;
|
|
677
|
-
this.
|
|
678
|
-
this.
|
|
678
|
+
this.uint16[o2 + 30] = v26;
|
|
679
|
+
this.uint16[o2 + 31] = v27;
|
|
679
680
|
return i;
|
|
680
681
|
}
|
|
681
682
|
}
|
|
682
683
|
|
|
683
|
-
|
|
684
|
-
register('
|
|
684
|
+
StructArrayLayout8i15ui1ul2f2ui64.prototype.bytesPerElement = 64;
|
|
685
|
+
register('StructArrayLayout8i15ui1ul2f2ui64', StructArrayLayout8i15ui1ul2f2ui64);
|
|
685
686
|
|
|
686
687
|
/**
|
|
687
688
|
* @internal
|
|
@@ -714,6 +715,43 @@ class StructArrayLayout1f4 extends StructArray {
|
|
|
714
715
|
StructArrayLayout1f4.prototype.bytesPerElement = 4;
|
|
715
716
|
register('StructArrayLayout1f4', StructArrayLayout1f4);
|
|
716
717
|
|
|
718
|
+
/**
|
|
719
|
+
* @internal
|
|
720
|
+
* Implementation of the StructArray layout:
|
|
721
|
+
* [0]: Uint16[1]
|
|
722
|
+
* [4]: Float32[2]
|
|
723
|
+
*
|
|
724
|
+
*/
|
|
725
|
+
class StructArrayLayout1ui2f12 extends StructArray {
|
|
726
|
+
uint8: Uint8Array;
|
|
727
|
+
uint16: Uint16Array;
|
|
728
|
+
float32: Float32Array;
|
|
729
|
+
|
|
730
|
+
_refreshViews() {
|
|
731
|
+
this.uint8 = new Uint8Array(this.arrayBuffer);
|
|
732
|
+
this.uint16 = new Uint16Array(this.arrayBuffer);
|
|
733
|
+
this.float32 = new Float32Array(this.arrayBuffer);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
public emplaceBack(v0: number, v1: number, v2: number) {
|
|
737
|
+
const i = this.length;
|
|
738
|
+
this.resize(i + 1);
|
|
739
|
+
return this.emplace(i, v0, v1, v2);
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
public emplace(i: number, v0: number, v1: number, v2: number) {
|
|
743
|
+
const o2 = i * 6;
|
|
744
|
+
const o4 = i * 3;
|
|
745
|
+
this.uint16[o2 + 0] = v0;
|
|
746
|
+
this.float32[o4 + 1] = v1;
|
|
747
|
+
this.float32[o4 + 2] = v2;
|
|
748
|
+
return i;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
StructArrayLayout1ui2f12.prototype.bytesPerElement = 12;
|
|
753
|
+
register('StructArrayLayout1ui2f12', StructArrayLayout1ui2f12);
|
|
754
|
+
|
|
717
755
|
/**
|
|
718
756
|
* @internal
|
|
719
757
|
* Implementation of the StructArray layout:
|
|
@@ -951,17 +989,17 @@ class SymbolInstanceStruct extends Struct {
|
|
|
951
989
|
get crossTileID() { return this._structArray.uint32[this._pos4 + 12]; }
|
|
952
990
|
set crossTileID(x: number) { this._structArray.uint32[this._pos4 + 12] = x; }
|
|
953
991
|
get textBoxScale() { return this._structArray.float32[this._pos4 + 13]; }
|
|
954
|
-
get
|
|
955
|
-
get
|
|
956
|
-
get
|
|
992
|
+
get collisionCircleDiameter() { return this._structArray.float32[this._pos4 + 14]; }
|
|
993
|
+
get textAnchorOffsetStartIndex() { return this._structArray.uint16[this._pos2 + 30]; }
|
|
994
|
+
get textAnchorOffsetEndIndex() { return this._structArray.uint16[this._pos2 + 31]; }
|
|
957
995
|
}
|
|
958
996
|
|
|
959
|
-
SymbolInstanceStruct.prototype.size =
|
|
997
|
+
SymbolInstanceStruct.prototype.size = 64;
|
|
960
998
|
|
|
961
999
|
export type SymbolInstance = SymbolInstanceStruct;
|
|
962
1000
|
|
|
963
1001
|
/** @internal */
|
|
964
|
-
export class SymbolInstanceArray extends
|
|
1002
|
+
export class SymbolInstanceArray extends StructArrayLayout8i15ui1ul2f2ui64 {
|
|
965
1003
|
/**
|
|
966
1004
|
* Return the SymbolInstanceStruct at the given location in the array.
|
|
967
1005
|
* @param index The index of the element.
|
|
@@ -989,6 +1027,31 @@ export class SymbolLineVertexArray extends StructArrayLayout3i6 {
|
|
|
989
1027
|
|
|
990
1028
|
register('SymbolLineVertexArray', SymbolLineVertexArray);
|
|
991
1029
|
|
|
1030
|
+
/** @internal */
|
|
1031
|
+
class TextAnchorOffsetStruct extends Struct {
|
|
1032
|
+
_structArray: TextAnchorOffsetArray;
|
|
1033
|
+
get textAnchor() { return this._structArray.uint16[this._pos2 + 0]; }
|
|
1034
|
+
get textOffset0() { return this._structArray.float32[this._pos4 + 1]; }
|
|
1035
|
+
get textOffset1() { return this._structArray.float32[this._pos4 + 2]; }
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
TextAnchorOffsetStruct.prototype.size = 12;
|
|
1039
|
+
|
|
1040
|
+
export type TextAnchorOffset = TextAnchorOffsetStruct;
|
|
1041
|
+
|
|
1042
|
+
/** @internal */
|
|
1043
|
+
export class TextAnchorOffsetArray extends StructArrayLayout1ui2f12 {
|
|
1044
|
+
/**
|
|
1045
|
+
* Return the TextAnchorOffsetStruct at the given location in the array.
|
|
1046
|
+
* @param index The index of the element.
|
|
1047
|
+
*/
|
|
1048
|
+
get(index: number): TextAnchorOffsetStruct {
|
|
1049
|
+
return new TextAnchorOffsetStruct(this, index);
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
register('TextAnchorOffsetArray', TextAnchorOffsetArray);
|
|
1054
|
+
|
|
992
1055
|
/** @internal */
|
|
993
1056
|
class FeatureIndexStruct extends Struct {
|
|
994
1057
|
_structArray: FeatureIndexArray;
|
|
@@ -1051,8 +1114,9 @@ export {
|
|
|
1051
1114
|
StructArrayLayout2ub2f12,
|
|
1052
1115
|
StructArrayLayout3ui6,
|
|
1053
1116
|
StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48,
|
|
1054
|
-
|
|
1117
|
+
StructArrayLayout8i15ui1ul2f2ui64,
|
|
1055
1118
|
StructArrayLayout1f4,
|
|
1119
|
+
StructArrayLayout1ui2f12,
|
|
1056
1120
|
StructArrayLayout1ul2ui8,
|
|
1057
1121
|
StructArrayLayout2ui4,
|
|
1058
1122
|
StructArrayLayout1ui2,
|
|
@@ -100,8 +100,9 @@ export const symbolInstance = createLayout([
|
|
|
100
100
|
{type: 'Uint16', name: 'useRuntimeCollisionCircles'},
|
|
101
101
|
{type: 'Uint32', name: 'crossTileID'},
|
|
102
102
|
{type: 'Float32', name: 'textBoxScale'},
|
|
103
|
-
{type: 'Float32', components: 2, name: 'textOffset'},
|
|
104
103
|
{type: 'Float32', name: 'collisionCircleDiameter'},
|
|
104
|
+
{type: 'Uint16', name: 'textAnchorOffsetStartIndex'},
|
|
105
|
+
{type: 'Uint16', name: 'textAnchorOffsetEndIndex'}
|
|
105
106
|
]);
|
|
106
107
|
|
|
107
108
|
export const glyphOffset = createLayout([
|
|
@@ -113,3 +114,8 @@ export const lineVertex = createLayout([
|
|
|
113
114
|
{type: 'Int16', name: 'y'},
|
|
114
115
|
{type: 'Int16', name: 'tileUnitDistanceFromAnchor'}
|
|
115
116
|
]);
|
|
117
|
+
|
|
118
|
+
export const textAnchorOffset = createLayout([
|
|
119
|
+
{type: 'Uint16', name: 'textAnchor'},
|
|
120
|
+
{type: 'Float32', components: 2, name: 'textOffset'}
|
|
121
|
+
]);
|
|
@@ -13,7 +13,8 @@ import {SymbolLayoutArray,
|
|
|
13
13
|
PlacedSymbolArray,
|
|
14
14
|
SymbolInstanceArray,
|
|
15
15
|
GlyphOffsetArray,
|
|
16
|
-
SymbolLineVertexArray
|
|
16
|
+
SymbolLineVertexArray,
|
|
17
|
+
TextAnchorOffsetArray
|
|
17
18
|
} from '../array_types.g';
|
|
18
19
|
|
|
19
20
|
import Point from '@mapbox/point-geometry';
|
|
@@ -333,6 +334,7 @@ export class SymbolBucket implements Bucket {
|
|
|
333
334
|
lineVertexArray: SymbolLineVertexArray;
|
|
334
335
|
features: Array<SymbolFeature>;
|
|
335
336
|
symbolInstances: SymbolInstanceArray;
|
|
337
|
+
textAnchorOffsets: TextAnchorOffsetArray;
|
|
336
338
|
collisionArrays: Array<CollisionArrays>;
|
|
337
339
|
sortKeyRanges: Array<SortKeyRange>;
|
|
338
340
|
pixelRatio: number;
|
|
@@ -412,6 +414,7 @@ export class SymbolBucket implements Bucket {
|
|
|
412
414
|
this.glyphOffsetArray = new GlyphOffsetArray();
|
|
413
415
|
this.lineVertexArray = new SymbolLineVertexArray();
|
|
414
416
|
this.symbolInstances = new SymbolInstanceArray();
|
|
417
|
+
this.textAnchorOffsets = new TextAnchorOffsetArray();
|
|
415
418
|
}
|
|
416
419
|
|
|
417
420
|
calculateGlyphDependencies(text: string, stack: {[_: number]: boolean}, textAlongLine: boolean, allowVerticalPlacement: boolean, doesAllowVerticalWritingMode: boolean) {
|
|
@@ -13,7 +13,6 @@ import {addDynamicAttributes} from '../data/bucket/symbol_bucket';
|
|
|
13
13
|
|
|
14
14
|
import {getAnchorAlignment, WritingMode} from '../symbol/shaping';
|
|
15
15
|
import ONE_EM from '../symbol/one_em';
|
|
16
|
-
import {evaluateVariableOffset, TextAnchor} from '../symbol/symbol_layout';
|
|
17
16
|
|
|
18
17
|
import {
|
|
19
18
|
SymbolIconUniformsType,
|
|
@@ -37,6 +36,7 @@ import type {SymbolLayerSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
|
37
36
|
import type {Transform} from '../geo/transform';
|
|
38
37
|
import type {ColorMode} from '../gl/color_mode';
|
|
39
38
|
import type {Program} from './program';
|
|
39
|
+
import type {TextAnchor} from '../style/style_layer/variable_text_anchor';
|
|
40
40
|
|
|
41
41
|
type SymbolTileRenderState = {
|
|
42
42
|
segments: SegmentVector;
|
|
@@ -65,11 +65,11 @@ export function drawSymbols(painter: Painter, sourceCache: SourceCache, layer: S
|
|
|
65
65
|
// Disable the stencil test so that labels aren't clipped to tile boundaries.
|
|
66
66
|
const stencilMode = StencilMode.disabled;
|
|
67
67
|
const colorMode = painter.colorModeForRenderPass();
|
|
68
|
-
const
|
|
68
|
+
const hasVariablePlacement = layer._unevaluatedLayout.hasValue('text-variable-anchor') || layer._unevaluatedLayout.hasValue('text-variable-anchor-offset');
|
|
69
69
|
|
|
70
70
|
//Compute variable-offsets before painting since icons and text data positioning
|
|
71
71
|
//depend on each other in this case.
|
|
72
|
-
if (
|
|
72
|
+
if (hasVariablePlacement) {
|
|
73
73
|
updateVariableAnchors(coords, painter, layer, sourceCache,
|
|
74
74
|
layer.layout.get('text-rotation-alignment'),
|
|
75
75
|
layer.layout.get('text-pitch-alignment'),
|
|
@@ -117,10 +117,9 @@ function calculateVariableRenderShift(
|
|
|
117
117
|
const {horizontalAlign, verticalAlign} = getAnchorAlignment(anchor);
|
|
118
118
|
const shiftX = -(horizontalAlign - 0.5) * width;
|
|
119
119
|
const shiftY = -(verticalAlign - 0.5) * height;
|
|
120
|
-
const variableOffset = evaluateVariableOffset(anchor, textOffset);
|
|
121
120
|
return new Point(
|
|
122
|
-
(shiftX / textBoxScale +
|
|
123
|
-
(shiftY / textBoxScale +
|
|
121
|
+
(shiftX / textBoxScale + textOffset[0]) * renderTextSize,
|
|
122
|
+
(shiftY / textBoxScale + textOffset[1]) * renderTextSize
|
|
124
123
|
);
|
|
125
124
|
}
|
|
126
125
|
|
|
@@ -281,7 +280,7 @@ function drawLayerSymbols(
|
|
|
281
280
|
|
|
282
281
|
const depthMode = painter.depthModeForSublayer(0, DepthMode.ReadOnly);
|
|
283
282
|
|
|
284
|
-
const
|
|
283
|
+
const hasVariablePlacement = layer._unevaluatedLayout.hasValue('text-variable-anchor') || layer._unevaluatedLayout.hasValue('text-variable-anchor-offset');
|
|
285
284
|
|
|
286
285
|
const tileRenderState: Array<SymbolTileRenderState> = [];
|
|
287
286
|
|
|
@@ -332,7 +331,7 @@ function drawLayerSymbols(
|
|
|
332
331
|
const labelPlaneMatrix = symbolProjection.getLabelPlaneMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, s);
|
|
333
332
|
const glCoordMatrix = symbolProjection.getGlCoordMatrix(coord.posMatrix, pitchWithMap, rotateWithMap, painter.transform, s);
|
|
334
333
|
|
|
335
|
-
const hasVariableAnchors =
|
|
334
|
+
const hasVariableAnchors = hasVariablePlacement && bucket.hasTextData();
|
|
336
335
|
const updateTextFitIcon = layer.layout.get('icon-text-fit') !== 'none' &&
|
|
337
336
|
hasVariableAnchors &&
|
|
338
337
|
bucket.hasIconData();
|
|
@@ -344,7 +343,7 @@ function drawLayerSymbols(
|
|
|
344
343
|
}
|
|
345
344
|
|
|
346
345
|
const matrix = painter.translatePosMatrix(coord.posMatrix, tile, translate, translateAnchor),
|
|
347
|
-
uLabelPlaneMatrix = (alongLine || (isText &&
|
|
346
|
+
uLabelPlaneMatrix = (alongLine || (isText && hasVariablePlacement) || updateTextFitIcon) ? identityMat4 : labelPlaneMatrix,
|
|
348
347
|
uglCoordMatrix = painter.translatePosMatrix(glCoordMatrix, tile, translate, translateAnchor, true);
|
|
349
348
|
|
|
350
349
|
const hasHalo = isSDF && layer.paint.get(isText ? 'text-halo-width' : 'icon-halo-width').constantOr(1) !== 0;
|
package/src/render/program.ts
CHANGED
|
@@ -89,6 +89,11 @@ export class Program<Us extends UniformBindings> {
|
|
|
89
89
|
}
|
|
90
90
|
gl.shaderSource(fragmentShader, fragmentSource);
|
|
91
91
|
gl.compileShader(fragmentShader);
|
|
92
|
+
|
|
93
|
+
if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {
|
|
94
|
+
throw new Error(`Could not compile fragment shader: ${gl.getShaderInfoLog(fragmentShader)}`);
|
|
95
|
+
}
|
|
96
|
+
|
|
92
97
|
gl.attachShader(this.program, fragmentShader);
|
|
93
98
|
|
|
94
99
|
const vertexShader = gl.createShader(gl.VERTEX_SHADER);
|
|
@@ -98,6 +103,11 @@ export class Program<Us extends UniformBindings> {
|
|
|
98
103
|
}
|
|
99
104
|
gl.shaderSource(vertexShader, vertexSource);
|
|
100
105
|
gl.compileShader(vertexShader);
|
|
106
|
+
|
|
107
|
+
if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
|
|
108
|
+
throw new Error(`Could not compile vertex shader: ${gl.getShaderInfoLog(vertexShader)}`);
|
|
109
|
+
}
|
|
110
|
+
|
|
101
111
|
gl.attachShader(this.program, vertexShader);
|
|
102
112
|
|
|
103
113
|
this.attributes = {};
|
|
@@ -113,6 +123,11 @@ export class Program<Us extends UniformBindings> {
|
|
|
113
123
|
}
|
|
114
124
|
|
|
115
125
|
gl.linkProgram(this.program);
|
|
126
|
+
|
|
127
|
+
if (!gl.getProgramParameter(this.program, gl.LINK_STATUS)) {
|
|
128
|
+
throw new Error(`Program failed to link: ${gl.getProgramInfoLog(this.program)}`);
|
|
129
|
+
}
|
|
130
|
+
|
|
116
131
|
gl.deleteShader(vertexShader);
|
|
117
132
|
gl.deleteShader(fragmentShader);
|
|
118
133
|
|
|
@@ -52,7 +52,6 @@ export type VectorTileSourceOptions = VectorSourceSpecification & {
|
|
|
52
52
|
* map.getSource('some id').setTiles(['https://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt']);
|
|
53
53
|
* ```
|
|
54
54
|
* @see [Add a vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/vector-source/)
|
|
55
|
-
* @see [Add a third party vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/third-party/)
|
|
56
55
|
*/
|
|
57
56
|
export class VectorTileSource extends Evented implements Source {
|
|
58
57
|
type: 'vector';
|
|
@@ -48,6 +48,10 @@ import type {VideoSourceSpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
|
48
48
|
* map.removeSource('some id'); // remove
|
|
49
49
|
* ```
|
|
50
50
|
* @see [Add a video](https://maplibre.org/maplibre-gl-js/docs/examples/video-on-a-map/)
|
|
51
|
+
*
|
|
52
|
+
* Note that when rendered as a raster layer, the layer's `raster-fade-duration` property will cause the video to fade in.
|
|
53
|
+
* This happens when playback is started, paused and resumed, or when the video's coordinates are updated. To avoid this behavior,
|
|
54
|
+
* set the layer's `raster-fade-duration` property to `0`.
|
|
51
55
|
*/
|
|
52
56
|
export class VideoSource extends ImageSource {
|
|
53
57
|
options: VideoSourceSpecification;
|
package/src/style/properties.ts
CHANGED
|
@@ -317,6 +317,10 @@ export class Layout<Props> {
|
|
|
317
317
|
this._values = (Object.create(properties.defaultPropertyValues) as any);
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
+
hasValue<S extends keyof Props>(name: S) {
|
|
321
|
+
return this._values[name].value !== undefined;
|
|
322
|
+
}
|
|
323
|
+
|
|
320
324
|
getValue<S extends keyof Props>(name: S) {
|
|
321
325
|
return clone(this._values[name].value);
|
|
322
326
|
}
|
package/src/style/style.ts
CHANGED
|
@@ -191,6 +191,12 @@ export type StyleSwapOptions = {
|
|
|
191
191
|
transformStyle?: TransformStyleFunction;
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
+
/**
|
|
195
|
+
* Specifies a layer to be added to a {@link Style}. In addition to a standard {@link LayerSpecification}
|
|
196
|
+
* or a {@link CustomLayerInterface}, a {@link LayerSpecification} with an embedded {@link SourceSpecification} can also be provided.
|
|
197
|
+
*/
|
|
198
|
+
export type AddLayerObject = LayerSpecification | (Omit<LayerSpecification, 'source'> & {source: SourceSpecification}) | CustomLayerInterface;
|
|
199
|
+
|
|
194
200
|
/**
|
|
195
201
|
* The Style base class
|
|
196
202
|
*/
|
|
@@ -362,7 +368,7 @@ export class Style extends Evented {
|
|
|
362
368
|
|
|
363
369
|
this.light = new Light(this.stylesheet.light);
|
|
364
370
|
|
|
365
|
-
this.map.setTerrain(this.stylesheet.terrain);
|
|
371
|
+
this.map.setTerrain(this.stylesheet.terrain ?? null);
|
|
366
372
|
|
|
367
373
|
this.fire(new Event('data', {dataType: 'style'}));
|
|
368
374
|
this.fire(new Event('style.load'));
|
|
@@ -848,7 +854,7 @@ export class Style extends Evented {
|
|
|
848
854
|
* @param options - Style setter options.
|
|
849
855
|
* @returns `this`.
|
|
850
856
|
*/
|
|
851
|
-
addLayer(layerObject:
|
|
857
|
+
addLayer(layerObject: AddLayerObject, before?: string, options: StyleSetterOptions = {}): this {
|
|
852
858
|
this._checkLoaded();
|
|
853
859
|
|
|
854
860
|
const id = layerObject.id;
|
|
@@ -858,7 +864,7 @@ export class Style extends Evented {
|
|
|
858
864
|
return;
|
|
859
865
|
}
|
|
860
866
|
|
|
861
|
-
let layer
|
|
867
|
+
let layer: ReturnType<typeof createStyleLayer>;
|
|
862
868
|
if (layerObject.type === 'custom') {
|
|
863
869
|
|
|
864
870
|
if (emitValidationErrors(this, validateCustomStyleLayer(layerObject))) return;
|
|
@@ -866,17 +872,17 @@ export class Style extends Evented {
|
|
|
866
872
|
layer = createStyleLayer(layerObject);
|
|
867
873
|
|
|
868
874
|
} else {
|
|
869
|
-
if (
|
|
870
|
-
this.addSource(id,
|
|
875
|
+
if ('source' in layerObject && typeof layerObject.source === 'object') {
|
|
876
|
+
this.addSource(id, layerObject.source);
|
|
871
877
|
layerObject = clone(layerObject);
|
|
872
|
-
layerObject =
|
|
878
|
+
layerObject = extend(layerObject, {source: id});
|
|
873
879
|
}
|
|
874
880
|
|
|
875
881
|
// this layer is not in the style.layers array, so we pass an impossible array index
|
|
876
882
|
if (this._validate(validateStyle.layer,
|
|
877
883
|
`layers.${id}`, layerObject, {arrayIndex: -1}, options)) return;
|
|
878
884
|
|
|
879
|
-
layer = createStyleLayer(layerObject);
|
|
885
|
+
layer = createStyleLayer(layerObject as LayerSpecification | CustomLayerInterface);
|
|
880
886
|
this._validateLayer(layer);
|
|
881
887
|
|
|
882
888
|
layer.setEventedParent(this, {layer: {id}});
|
|
@@ -994,7 +1000,7 @@ export class Style extends Evented {
|
|
|
994
1000
|
* @param id - id of the desired layer
|
|
995
1001
|
* @returns a layer, if one with the given `id` exists
|
|
996
1002
|
*/
|
|
997
|
-
getLayer(id: string): StyleLayer {
|
|
1003
|
+
getLayer(id: string): StyleLayer | undefined {
|
|
998
1004
|
return this._layers[id];
|
|
999
1005
|
}
|
|
1000
1006
|
|
|
@@ -14,12 +14,7 @@ import {
|
|
|
14
14
|
CrossFaded
|
|
15
15
|
} from '../properties';
|
|
16
16
|
|
|
17
|
-
import type {Color} from '@maplibre/maplibre-gl-style-spec';
|
|
18
|
-
import type {Padding} from '@maplibre/maplibre-gl-style-spec';
|
|
19
|
-
|
|
20
|
-
import type {Formatted} from '@maplibre/maplibre-gl-style-spec';
|
|
21
|
-
|
|
22
|
-
import type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec';
|
|
17
|
+
import type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';
|
|
23
18
|
import {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
24
19
|
|
|
25
20
|
|
|
@@ -14,12 +14,7 @@ import {
|
|
|
14
14
|
CrossFaded
|
|
15
15
|
} from '../properties';
|
|
16
16
|
|
|
17
|
-
import type {Color} from '@maplibre/maplibre-gl-style-spec';
|
|
18
|
-
import type {Padding} from '@maplibre/maplibre-gl-style-spec';
|
|
19
|
-
|
|
20
|
-
import type {Formatted} from '@maplibre/maplibre-gl-style-spec';
|
|
21
|
-
|
|
22
|
-
import type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec';
|
|
17
|
+
import type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';
|
|
23
18
|
import {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
24
19
|
|
|
25
20
|
export type CircleLayoutProps = {
|
|
@@ -14,12 +14,7 @@ import {
|
|
|
14
14
|
CrossFaded
|
|
15
15
|
} from '../properties';
|
|
16
16
|
|
|
17
|
-
import type {Color} from '@maplibre/maplibre-gl-style-spec';
|
|
18
|
-
import type {Padding} from '@maplibre/maplibre-gl-style-spec';
|
|
19
|
-
|
|
20
|
-
import type {Formatted} from '@maplibre/maplibre-gl-style-spec';
|
|
21
|
-
|
|
22
|
-
import type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec';
|
|
17
|
+
import type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';
|
|
23
18
|
import {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
24
19
|
|
|
25
20
|
|
|
@@ -14,12 +14,7 @@ import {
|
|
|
14
14
|
CrossFaded
|
|
15
15
|
} from '../properties';
|
|
16
16
|
|
|
17
|
-
import type {Color} from '@maplibre/maplibre-gl-style-spec';
|
|
18
|
-
import type {Padding} from '@maplibre/maplibre-gl-style-spec';
|
|
19
|
-
|
|
20
|
-
import type {Formatted} from '@maplibre/maplibre-gl-style-spec';
|
|
21
|
-
|
|
22
|
-
import type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec';
|
|
17
|
+
import type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';
|
|
23
18
|
import {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
24
19
|
|
|
25
20
|
export type FillLayoutProps = {
|
|
@@ -14,12 +14,7 @@ import {
|
|
|
14
14
|
CrossFaded
|
|
15
15
|
} from '../properties';
|
|
16
16
|
|
|
17
|
-
import type {Color} from '@maplibre/maplibre-gl-style-spec';
|
|
18
|
-
import type {Padding} from '@maplibre/maplibre-gl-style-spec';
|
|
19
|
-
|
|
20
|
-
import type {Formatted} from '@maplibre/maplibre-gl-style-spec';
|
|
21
|
-
|
|
22
|
-
import type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec';
|
|
17
|
+
import type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';
|
|
23
18
|
import {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
24
19
|
|
|
25
20
|
|
|
@@ -14,12 +14,7 @@ import {
|
|
|
14
14
|
CrossFaded
|
|
15
15
|
} from '../properties';
|
|
16
16
|
|
|
17
|
-
import type {Color} from '@maplibre/maplibre-gl-style-spec';
|
|
18
|
-
import type {Padding} from '@maplibre/maplibre-gl-style-spec';
|
|
19
|
-
|
|
20
|
-
import type {Formatted} from '@maplibre/maplibre-gl-style-spec';
|
|
21
|
-
|
|
22
|
-
import type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec';
|
|
17
|
+
import type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';
|
|
23
18
|
import {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
24
19
|
|
|
25
20
|
|
|
@@ -14,12 +14,7 @@ import {
|
|
|
14
14
|
CrossFaded
|
|
15
15
|
} from '../properties';
|
|
16
16
|
|
|
17
|
-
import type {Color} from '@maplibre/maplibre-gl-style-spec';
|
|
18
|
-
import type {Padding} from '@maplibre/maplibre-gl-style-spec';
|
|
19
|
-
|
|
20
|
-
import type {Formatted} from '@maplibre/maplibre-gl-style-spec';
|
|
21
|
-
|
|
22
|
-
import type {ResolvedImage} from '@maplibre/maplibre-gl-style-spec';
|
|
17
|
+
import type {Color, Formatted, Padding, ResolvedImage, VariableAnchorOffsetCollection} from '@maplibre/maplibre-gl-style-spec';
|
|
23
18
|
import {StylePropertySpecification} from '@maplibre/maplibre-gl-style-spec';
|
|
24
19
|
|
|
25
20
|
export type LineLayoutProps = {
|